gregoriusxu / booksleeve

Automatically exported from code.google.com/p/booksleeve
Other
0 stars 0 forks source link

ConnectionUtils sample? #29

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Is there a sample of how to use ConnectionUtils?

Also will this handle a failure if one Redis instance goes down?

Original issue reported on code.google.com by danny.ge...@gmail.com on 29 Nov 2012 at 11:20

GoogleCodeExporter commented 8 years ago
There isn't a real sample, but you could take a look at Tests/Connection.cs
If you are using Redis sentinel you should use the 
ConnectionUtils.SelectConfiguration() to connect to the sentinels and let that 
report the master address.

If you're not using sentinels you could use ConnectionUtils.Connect() like so:
ConnectionUtils.Connect('10.0.0.1,10.0.0.2', false)
This will connect to one of the IP addresses specified and it will be the 
master.

It does not handle automatic failover's but that is pretty easy to solve 
yourself. As the Connection's State will either be Closed or Closing, in which 
case you use the ConnectionUtils.Connect() again to let it connect to the new 
master

Original comment by johanalk...@gmail.com on 3 Dec 2012 at 3:20

GoogleCodeExporter commented 8 years ago
Ok, I will try this out, then maybe I'll blog about it.  Question, what about 
Redis calls that were already in the Task Queue.  Would they be dropped if the 
connection failed?  I want to ensure that nothing is lost.  Basically to have 
those calls wait until an Redis Server is ready.  Only fail if nothing at all 
is available for say 60 seconds or so.

Original comment by danny.ge...@gmail.com on 4 Dec 2012 at 4:31

GoogleCodeExporter commented 8 years ago
In the event of an unexpected failover, even something that previously 
succeeded may not have happened as far as the slave you end up at is concerned. 
I think you need to be more specific as to your requirements.

But to put it in context: for our own layer that we build on top of BookSleeve, 
we do indeed do an amount of local buffereing if things get ill.

Original comment by marc.gravell on 4 Dec 2012 at 8:07

GoogleCodeExporter commented 8 years ago
I think i got something worked out.  Thanks for your help.  I'm gonna blog 
about it when I'm done.

Original comment by danny.ge...@gmail.com on 4 Dec 2012 at 8:09

GoogleCodeExporter commented 8 years ago
This is addressed in StackExchange.Redis, the successor to BookSleeve, which 
has a dedicated configuration API, and which handles failuire

Original comment by marc.gravell on 20 Mar 2014 at 12:08