class RedisWmrs::Dispatcher
Constants
- DEFAULT_SLAVE_COMMANDS
- MASTER_SLAVE_COMMANDS
Attributes
master[R]
options[R]
slave[R]
Public Class Methods
new(master, slave, options)
click to toggle source
# File lib/redis_wmrs/dispatcher.rb, line 27 def initialize(master, slave, options) @master, @slave = master, slave @both_cmds = options[:both] || MASTER_SLAVE_COMMANDS @slave_cmds = options[:slave] || DEFAULT_SLAVE_COMMANDS end
Public Instance Methods
call(command, &block)
click to toggle source
# File lib/redis_wmrs/dispatcher.rb, line 53 def call(command, &block) __dispatch__(*command){|c|c.call(command, &block)} end
call_loop(command, &block)
click to toggle source
# File lib/redis_wmrs/dispatcher.rb, line 57 def call_loop(command, &block) __dispatch__(*command){|c|c.call_loop(command, &block)} end
call_with_timeout(command, timeout, &blk)
click to toggle source
# File lib/redis_wmrs/dispatcher.rb, line 61 def call_with_timeout(command, timeout, &blk) __dispatch__(*command){|c|c.call_with_timeout(command, timeout, &blk)} end
call_without_timeout(command, &blk)
click to toggle source
# File lib/redis_wmrs/dispatcher.rb, line 65 def call_without_timeout(command, &blk) __dispatch__(*command){|c|c.call_without_timeout(command, &blk)} end
connect()
click to toggle source
# File lib/redis_wmrs/dispatcher.rb, line 49 def connect ; __both__{|c| c.connect }; return self; end
db=(db)
click to toggle source
# File lib/redis_wmrs/dispatcher.rb, line 41 def db=(db) __both__{|c| c.db = db}; return db end
disconnect()
click to toggle source
# File lib/redis_wmrs/dispatcher.rb, line 50 def disconnect; __both__{|c| c.disconnect}; return self; end
ids()
click to toggle source
# File lib/redis_wmrs/dispatcher.rb, line 33 def ids __map__ &:id end
locations()
click to toggle source
# File lib/redis_wmrs/dispatcher.rb, line 37 def locations __map__ &:location end
logger=(v)
click to toggle source
# File lib/redis_wmrs/dispatcher.rb, line 45 def logger=(v) __both__{|c| c.logger = v}; return v end
reconnect()
click to toggle source
# File lib/redis_wmrs/dispatcher.rb, line 51 def reconnect ; __both__{|c| c.reconnect }; return self; end
Private Instance Methods
__both__() { |master| ... }
click to toggle source
# File lib/redis_wmrs/dispatcher.rb, line 77 def __both__ yield(@master) yield(@slave) end
__dispatch__(command, *, &blk)
click to toggle source
# File lib/redis_wmrs/dispatcher.rb, line 88 def __dispatch__(command, *, &blk) m = case when @slave_cmds.include?(command) then :__slave__ when @both_cmds.include?(command) then :__both__ else :__master__ end send(m, &blk) end
__map__() { |master| ... }
click to toggle source
# File lib/redis_wmrs/dispatcher.rb, line 84 def __map__ [yield(@master), yield(@slave)] end
__master__() { |master| ... }
click to toggle source
# File lib/redis_wmrs/dispatcher.rb, line 81 def __master__; yield(@master); end
__slave__() { |slave| ... }
click to toggle source
# File lib/redis_wmrs/dispatcher.rb, line 82 def __slave__ ; yield(@slave ); end