module Knockoff
Constants
- VERSION
Attributes
default_target[R]
enabled[RW]
Public Class Methods
base_transaction_depth()
click to toggle source
# File lib/knockoff.rb, line 52 def base_transaction_depth @base_transaction_depth ||= begin testcase = ActiveSupport::TestCase if defined?(testcase) && testcase.respond_to?(:use_transactional_fixtures) && testcase.try(:use_transactional_fixtures) 1 else 0 end end end
clear_all_active_connections!()
click to toggle source
# File lib/knockoff.rb, line 31 def clear_all_active_connections! replica_pool.clear_all_active_connections! end
config()
click to toggle source
# File lib/knockoff.rb, line 48 def config @config ||= Config.new end
default_target=(target)
click to toggle source
# File lib/knockoff.rb, line 23 def default_target=(target) @default_target = Base.new(target).target end
disconnect_all!()
click to toggle source
Iterates through the replica pool and calls disconnect on each one's connection.
# File lib/knockoff.rb, line 36 def disconnect_all! replica_pool.disconnect_all_replicas! end
establish_new_connections!(new_config)
click to toggle source
Updates the config (both internal representation and the ActiveRecord::Base.configuration) with the new config, and then reconnects each replica connection in the replica pool.
# File lib/knockoff.rb, line 43 def establish_new_connections!(new_config) config.update_replica_configs(new_config) replica_pool.reconnect_all_replicas! end
on_primary(&block)
click to toggle source
# File lib/knockoff.rb, line 19 def on_primary(&block) Base.new(:primary).run(&block) end
on_replica(check_transaction: true, &block)
click to toggle source
# File lib/knockoff.rb, line 15 def on_replica(check_transaction: true, &block) Base.new(:replica, check_transaction: check_transaction).run(&block) end
replica_pool()
click to toggle source
# File lib/knockoff.rb, line 27 def replica_pool @replica_pool ||= ReplicaConnectionPool.new(config.replica_database_keys) end