package com.ltgk.framework.listener;

import org.springframework.data.redis.connection.RedisClusterConnection;
import org.springframework.data.redis.connection.RedisClusterNode;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.stereotype.Component;

@Component
public class RedisClusterNodeUtil {

    private final RedisConnectionFactory redisConnectionFactory;

    public RedisClusterNodeUtil(RedisConnectionFactory redisConnectionFactory) {
        this.redisConnectionFactory = redisConnectionFactory;
    }

    public Iterable<RedisClusterNode> getClusterNodes() {
        RedisClusterConnection clusterConnection = redisConnectionFactory.getClusterConnection();
        return clusterConnection.clusterGetNodes();
    }
}
