private void HandleFailover(IRedisClientsManager clientsManager)
{
try
{
if (OnFailover != null)
OnFailover(this);
if (masterClient != null)
{
//New thread-safe client with same connection info as connected master
using (var currentlySubscribedClient = ((RedisClient)masterClient).CloneClient())
{
Interlocked.CompareExchange(ref doOperation, Operation.Reset, doOperation);
foreach (var channel in Channels)
{
currentlySubscribedClient.PublishMessage(channel, ControlCommand.Control);
}
}
}
else
{
Restart();
}
}
catch (Exception ex)
{
if (this.OnError != null) this.OnError(ex);
Log.Warn("Error trying to UnSubscribeFromChannels in OnFailover. Restarting...", ex);
Restart();
}
}