Sha256: d73897e6f7d881032fec7687c41e68e7c999e7e31b03b82d70619c76ab918d74

Contents?: true

Size: 426 Bytes

Versions: 6

Compression:

Stored size: 426 Bytes

Contents

module ActiveRecord::Turntable
  class SlaveRegistry
    extend ActiveSupport::PerThreadRegistry

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

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

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
activerecord-turntable-4.4.1 lib/active_record/turntable/slave_registry.rb
activerecord-turntable-4.4.0 lib/active_record/turntable/slave_registry.rb
activerecord-turntable-4.3.0 lib/active_record/turntable/slave_registry.rb
activerecord-turntable-4.2.0 lib/active_record/turntable/slave_registry.rb
activerecord-turntable-4.1.0 lib/active_record/turntable/slave_registry.rb
activerecord-turntable-4.0.0 lib/active_record/turntable/slave_registry.rb