Sha256: 7a44b4d42d61ba2b28f8d972e529120144e29028a676ec0c14d15622286c6d2a
Contents?: true
Size: 1.09 KB
Versions: 3
Compression:
Stored size: 1.09 KB
Contents
module RedisFailover # Provides manual failover support to a new master. module Manual extend self # Path for manual failover communication. ZNODE_PATH = '/redis_failover_manual'.freeze # Denotes that any slave can be used as a candidate for promotion. ANY_SLAVE = "ANY_SLAVE".freeze # Performs a manual failover. If options is empty, a random slave will # be used as a failover candidate. # # @param [ZK] zk the ZooKeeper client # @param [Hash] options the options used for manual failover # @option options [String] :host the host of the failover candidate # @option options [String] :port the port of the failover candidate def failover(zk, options = {}) create_path(zk) node = options.empty? ? ANY_SLAVE : "#{options[:host]}:#{options[:port]}" zk.set(ZNODE_PATH, node) end private # Creates the znode path used for coordinating manual failovers. # # @param [ZK] zk the ZooKeeper cilent def create_path(zk) zk.create(ZNODE_PATH) rescue ZK::Exceptions::NodeExists # best effort end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
redis_failover-0.8.3 | lib/redis_failover/manual.rb |
redis_failover-0.8.2 | lib/redis_failover/manual.rb |
redis_failover-0.8.1 | lib/redis_failover/manual.rb |