lib/kwery/shard/state.rb
def start_config_update_thread
        Thread.new {
          sleep 5
          loop do
            @backends.each do |rs|
              client = Kwery::Client::Batch.new
              results = client.raft_leader(rs)
              leader = results
                .sort_by { |res| res[:current_term] }
                .map { |res| res[:leader_id] }
                .last
              @leaders[rs] = leader
            end

            # some backends are unknown, poll more quickly
            if @leaders.values.any? { |v| v.nil? }
              sleep 5
            else
              sleep 60
            end
          end
        }
      end
# TODO: support some kind of interrupt so that a "config_reload_hint" response
#       to a query can perform a faster poll
# TODO: make intervals configurable
support some kind of interrupt so that a "config_reload_hint" response
to a query can perform a faster poll
TODO: make intervals configurable
support some kind of interrupt so that a " config_reload_hint " response to a query can perform a faster poll TODO : make intervals configurable
def start_config_update_thread
        Thread.new {
          sleep 5
          loop do
            @backends.each do |rs|
              client = Kwery::Client::Batch.new
              results = client.raft_leader(rs)
              leader = results
                .sort_by { |res| res[:current_term] }
                .map { |res| res[:leader_id] }
                .last
              @leaders[rs] = leader
            end
            if @leaders.values.any? { |v| v.nil? }
              sleep 5
            else
              sleep 60
            end
          end
        }
      end
def start_config_update_thread Thread . new { sleep 5 loop do @backends . each do | rs | client = Kwery :: Client :: Batch . new results = client . raft_leader ( rs ) leader = results . sort_by { | res | res [ :current_term ] } . map { | res | res [ :leader_id ] } . last @leaders [ rs ] = leader end if @leaders . values . any? { | v | v . nil? } sleep 5 else sleep 60 end end } end
TODO: support some kind of interrupt so that a "config_reload_hint" response
to a query can perform a faster poll
TODO: make intervals configurable
TODO : support some kind of interrupt so that a " config_reload_hint " response to a query can perform a faster poll TODO : make intervals configurable
# some backends are unknown, poll more quickly