Sha256: c1015c58b39d7aa1e08e0486f17ee054687c290e25de528dee13e25822694e91
Contents?: true
Size: 855 Bytes
Versions: 6
Compression:
Stored size: 855 Bytes
Contents
module ActiveRecord::Turntable class ShardRegistry ShardMap = Struct.new(:range, :shard) do delegate :connection, :connection_pool, :name, to: :shard end attr_reader :cluster, :shard_maps def initialize(cluster) @cluster = cluster @shards_names_hash = {}.with_indifferent_access @shard_maps = [] end def add(setting) shard = (@shards_names_hash[setting.name] ||= Shard.new(cluster, setting.name, setting.slaves)) @shard_maps << ShardMap.new(setting.range, shard) @shard_maps.sort_by! { |m| m.range.min } end def shards @shards_names_hash.values end alias_method :all, :shards def release! shards.each do |shard| shard.connection_pool.clear_all_connections! end end def [](name) @shards_names_hash[name] end end end
Version data entries
6 entries across 6 versions & 1 rubygems