class Tarantool::EMDB::OneShardWrite
Public Class Methods
new(replicas, response, feed)
click to toggle source
# File lib/tarantool/em_db.rb, line 122 def initialize(replicas, response, feed) @replicas_origin = replicas @replicas = replicas.dup @i = replicas.size @response = response @feed = feed end
Public Instance Methods
call(result=INITIAL)
click to toggle source
# File lib/tarantool/em_db.rb, line 137 def call(result=INITIAL) result = _parse_iproto(result) unless result == INITIAL case result when INITIAL, ::IProto::ConnectionError, ::Tarantool::NonMaster rotate! if Exception === result rotate! until @i <= 0 || (repl = @replicas[0]).could_be_connected? if @i <= 0 EM.next_tick Curry1.new(@feed, NoMasterError.new("no available master connections")) return end repl.send_request(@response.request_type, @response.body, self) when Exception @feed.call result else @replicas_origin.replace @replicas @feed.call @response.parse_response_for_cb(result) end end
rotate!()
click to toggle source
# File lib/tarantool/em_db.rb, line 130 def rotate! if @i > 0 @i -= 1 @replicas.rotate! end end