module ReplicaPools
Constants
- VERSION
Public Class Methods
config()
click to toggle source
# File lib/replica_pools.rb, line 22 def config @config ||= ReplicaPools::Config.new end
current()
click to toggle source
# File lib/replica_pools.rb, line 41 def current proxy.current end
log(level, message)
click to toggle source
# File lib/replica_pools.rb, line 62 def log(level, message) logger.send(level, "[ReplicaPools] #{message}") end
logger()
click to toggle source
# File lib/replica_pools.rb, line 66 def logger ActiveRecord::Base.logger end
next_replica!()
click to toggle source
# File lib/replica_pools.rb, line 45 def next_replica! proxy.next_replica! end
pools()
click to toggle source
# File lib/replica_pools.rb, line 58 def pools Thread.current[:replica_pools] ||= ReplicaPools::Pools.new end
proxy()
click to toggle source
# File lib/replica_pools.rb, line 34 def proxy Thread.current[:replica_pools_proxy] ||= ReplicaPools::ConnectionProxy.new( ActiveRecord::Base, ReplicaPools.pools ) end
setup!()
click to toggle source
# File lib/replica_pools.rb, line 26 def setup! ConnectionProxy.generate_safe_delegations ActiveRecord::Base.send(:extend, ReplicaPools::Hijack) log :info, "Proxy loaded with: #{pools.keys.join(', ')}" end
with_leader() { || ... }
click to toggle source
# File lib/replica_pools.rb, line 53 def with_leader raise LeaderDisabled.new if ReplicaPools.config.disable_leader proxy.with_leader{ yield } end
with_pool(*a) { || ... }
click to toggle source
# File lib/replica_pools.rb, line 49 def with_pool(*a) proxy.with_pool(*a){ yield } end