Class: ActiveRecord::Turntable::SlaveRegistry

Inherits:
Object
  • Object
show all
Extended by:
ActiveSupport::PerThreadRegistry
Defined in:
lib/active_record/turntable/slave_registry.rb

Instance Method Summary collapse

Constructor Details

#initializeSlaveRegistry

Returns a new instance of SlaveRegistry.



5
6
7
# File 'lib/active_record/turntable/slave_registry.rb', line 5

def initialize
  @registry = Hash.new { |h, k| h[k] = {} }
end

Instance Method Details

#clear_for!(shard) ⇒ Object



17
18
19
# File 'lib/active_record/turntable/slave_registry.rb', line 17

def clear_for!(shard)
  @registry[shard].clear
end

#set_slave_for(shard, target_slave) ⇒ Object



13
14
15
# File 'lib/active_record/turntable/slave_registry.rb', line 13

def set_slave_for(shard, target_slave)
  @registry[shard][:current_slave] = target_slave
end

#slave_for(shard) ⇒ Object



9
10
11
# File 'lib/active_record/turntable/slave_registry.rb', line 9

def slave_for(shard)
  @registry[shard][:current_slave]
end