Description
Hello!
In Centrifuge/Centrifugo I used to require explicit Redis Cluster configuration (i.e. telling in the configuration that the Redis setup is cluster), because in Cluster mode Centrifuge library starts generating keys a bit differently (using hash tags).
But it seems it's not very convenient because Cloud providers provide Redis URL like redis://...
and under the hood can be standalone Redis or Redis Cluster. So users can't just re-use endpoint for starting Centrifugo.
I now decided that it's time to detect whether it's cluster or not automatically, but the only way I found to understand whether the underlying rueidis Client is a clusterClient
is sth like this:
client, _ = rueidis.NewClient(...)
if strings.Contains(strings.ToLower(fmt.Sprintf("%T", client)), "cluster") {
// Redis is a Redis Cluster.
}
I.e. looking at underlying interface type. Which is of course hacky.
I could issue extra command myself to Redis, but I think it's not a good idea given how many Redis implementations we have these days – so would prefer relying on rueidis logic. Also, I can not always generate keys in Redis Cluster format for keeping backwards compatibility and having a bit more clean keys in non-cluster scenario.
Maybe I missed some way? If not - can we add sth native for doing such a check? Given rueidis.Client
is an interface, what would be a preferred way to support the check of underlying client natively in rueidis
?
Activity