package com.chushang.redis.config.properties;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * @auther: zhao
 * @date: 2024/4/29 15:52
 */
@Data
@RefreshScope
@Configuration
@ConfigurationProperties(prefix = "config.redis")
public class RedissonProperties {

    private String prefix;
    /**
     * 线程池数量,默认值 = 当前处理核数量 * 2
     */
    private int threads = 4;

    /**
     * Netty线程池数量,默认值 = 当前处理核数量 * 2
     */
    private int nettyThreads = 8;

    private int timeout = 50000;
    /**
     * 密码
     */
    private String username;
    /**
     * 密码
     */
    private String password;
    /**
     * 客户端名称
     */
    private String clientName;
    /**
     * 单机服务配置
     */
    private SingleServerConfig singleServerConfig;
    /**
     * 集群服务配置
     */
    private ClusterServersConfig clusterServersConfig;
    /**
     * 哨兵服务配置
     */
    private SentinelServersConfig sentinelServersConfig;

    @Data
    @NoArgsConstructor
    public static class SingleServerConfig {
        /**
         * 地址
         */
        private String address;
        /**
         * database
         */
        private int database = 0;
    }
    @Data
    @NoArgsConstructor
    public static class ClusterServersConfig {
        /**
         * database
         */
        private int database = 0;
        /**
         * 集群
         */
        private String nodes;
    }

    /**
     * 哨兵
     */
    @Data
    @NoArgsConstructor
    public static class SentinelServersConfig {
        /**
         * 主
         */
        private String masterName;
        private int database = 0;
        /**
         * 地址
         */
        private String nodes;
    }
}
