Code Monkey home page Code Monkey logo

Comments (5)

dim avatar dim commented on August 11, 2024

Or you could keep a clone of your @sentinels_options as @original_sentinels_options and do:

def try_next_sentinel
  sentinel_options = @sentinels_options.shift
  if sentinel_options
    # ...
  else
    @sentinels_options = @original_sentinel_options.clone
    raise Redis::CannotConnectError
  end
end

from redis-sentinel.

flyerhzm avatar flyerhzm commented on August 11, 2024

@dim I have fixed in HEAD code, please try and let me know if it works

from redis-sentinel.

dim avatar dim commented on August 11, 2024

Hmm, it works but I am a little concerned about the logic in the approach:

def try_next_sentinel
  sentinel_options = @sentinels_options.shift
  @sentinels_options.push sentinel_options
  if sentinel_options
    ...
end

Because you are pushing the options straight back into the array, sentinel_options can never be nil, so you can safely reduce the method down to:

def try_next_sentinel
  sentinel_options = @sentinels_options.shift
  @sentinels_options.push sentinel_options
  @logger.debug "Trying next sentinel: #{sentinel_options[:host]}:#{sentinel_options[:port]}" if @logger && @logger.debug?
  @current_sentinel = Redis.new sentinel_options
end

from redis-sentinel.

flyerhzm avatar flyerhzm commented on August 11, 2024

@dim thanks, I have update the code and released 1.4.1 version.

from redis-sentinel.

dim avatar dim commented on August 11, 2024

Hmm, sorry, we made a mistake while testing, seems like you should yank 1.4.1. Will send a patch request shortly.

from redis-sentinel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.