sewenew / redis-plus-plus

Redis client written in C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[QUESTION] How to control redis++ reconnect? such as reconnect interval, health status etc

lisay-yan opened this issue · comments

Before Asking A Question
The README.md file has a detailed introduction with examples on how to use redis-plus-plus, and redis.h has doxgen style comments for most commands. Before asking a question, please try to find answers with these two files.

For general questions on redis-plus-plus, you can ask questions at StackOverflow with redis tag, and normally, you'll get faster response on StackOverflow.

However, if you still don't get answers, feel free to ask a question here.

Describe the problem
Initially, I set one of redis cluster IP to redis++, and itself auto discover the cluster status, and connect to all other nodes automatically.
My questions is
[1] In case of one node IP unreachable, how to control Redis++ reconnect behavior? Is there a configurable reconnect interval?
I am just worried immediately retry to cost too many fds.

[2] Can I watch Redis++ connPool status to know about redis node health status?

[3] Is it possible to change another Host for running redis++ instance?

[1] In case of one node IP unreachable, how to control Redis++ reconnect behavior? Is there a configurable reconnect interval? I am just worried immediately retry to cost too many fds.

There's no reconnect interval. redis-plus-plus reconnects lazily, i.e. reconnect when you send another command to Redis with the broken connection. So it's the library user that controls the frequency of retry.

[2] Can I watch Redis++ connPool status to know about redis node health status?

ConnectionPool is internel implementation details, you should try to watch its status.

[3] Is it possible to change another Host for running redis++ instance?

Do you mean that adding a new node to Redis Cluster? If that's the case, redis-plus-plus will automatically find it.

Regards

@sewenew

[1] That is clear for me. Thanks
[2] At least, I need to know the general status of ConnectionPool, such as
Connected (connection ok to all redis cluster nodes)
Partial connected (connection partial ok to redis cluster nodes)
Disconnected (no connection to redis cluster at all)

User may raise or clean ALARM according the status.
[3] I mean switch between two different redis cluster servers rather than node changes within a cluster.
Is it possible?

At least, I need to know the general status of ConnectionPool. User may raise or clean ALARM according the status.

When you call Redis API, and it throws some exception, you can raise ALARM according the exception. Since there're multiple connections, and it's hard to describe the general status. Some connections are broken, but it doesn't means you cannot send command to Redis, e.g. when the lib picks a broken connection, it tries to reconnect to it before sending command, or it might pick a healthy connection to do the work. So, normal, the end user does not need to care the status of connections. Instead, they only need to care about whether the command has been sent successfully. If not, what the exception is.

I mean switch between two different redis cluster servers rather than node changes within a cluster. Is it possible?

NO, you cannot do that. Instead, you have to create another RedisCluster object.

Since there's no update, I'll close this issue.