Sha256: 3f0de747c2f5d903d0410a5a267e5861d35bc8f6715ba14209d263c22b76d323
Contents?: true
Size: 855 Bytes
Versions: 12
Compression:
Stored size: 855 Bytes
Contents
module ActiveRecord module ShardFor # @abstract Subclass and override [#route] to inplement class ConnectionRouter attr_reader :cluster_config # @param [ActiveRecord::ShardFor::ClusterConfig] def initialize(cluster_config) @cluster_config = cluster_config end # Fetch shard by sharding key # @param [Object] key routing key def fetch_connection_name(key) cluster_config.fetch route(key) end # Decide routing for shard. # Override this method in subclass. # @param [Object] key sharding key def route(_key) raise NotImplementedError.new, 'Please impement this method' end private # @return [Integer] count of registered connection def connection_count cluster_config.connections.count end end end end
Version data entries
12 entries across 12 versions & 1 rubygems