How does the ServiceStack PooledRedisClientManager work?

According to git commit reports, ServiceStack has recently added fault tolerance support. Initially, I assumed that this meant that I could delete one of my Redis instances, and my combined client manager would elegantly manage the rollback and try to connect to one of my alternate Redis instances. Unfortunately, my code just loads and says that it cannot connect to the original Redis instance.

I am currently running Redis 2.6.12 instances on Windows, with a master on port 6379 and a slave on 6380, with clock mechanisms configured to automatically move the slave to the master if the master goes down. I am currently creating an instance of my client manager as follows:

PooledRedisClientManager pooledClientManager = new PooledRedisClientManager(new string[1] { "localhost:6379"}, new string[1] {"localhost:6380"}); 

where the first array is the read and write hosts (for the master), and the second array is read-only (for the slave).

When I complete the master on port 6379, the sentries advance the slave to the master. Now, when I try to run my code in C #, instead of switching to port 6380, it just crashes and returns the error "failed to connect to the redis instance on localhost: 6379".

Is there a way around this, or will a switch to another resource just not work the way I want?

+6
source share
1 answer

PooledRedisClientManager.FailoverTo allows you to reset which are read / write hosts vs readonly hosts and restart the factory. This allows you to switch quickly without having to re-create clients.

+4
source

Source: https://habr.com/ru/post/948595/


All Articles