class ActiveRecord::ConnectionAdapters::MakaraAbstractAdapter
Constants
- SQL_ALL_MATCHERS
- SQL_MASTER_MATCHERS
- SQL_SKIP_STICKINESS_MATCHERS
- SQL_SLAVE_MATCHERS
Public Class Methods
new(config)
click to toggle source
Calls superclass method
Makara::Proxy::new
# File lib/active_record/connection_adapters/makara_abstract_adapter.rb, line 119 def initialize(config) @error_handler = ::ActiveRecord::ConnectionAdapters::MakaraAbstractAdapter::ErrorHandler.new @control = ActiveRecordPoolControl.new(self) super(config) end
Public Instance Methods
sql_all_matchers()
click to toggle source
# File lib/active_record/connection_adapters/makara_abstract_adapter.rb, line 111 def sql_all_matchers SQL_ALL_MATCHERS end
sql_master_matchers()
click to toggle source
# File lib/active_record/connection_adapters/makara_abstract_adapter.rb, line 103 def sql_master_matchers SQL_MASTER_MATCHERS end
sql_skip_stickiness_matchers()
click to toggle source
# File lib/active_record/connection_adapters/makara_abstract_adapter.rb, line 115 def sql_skip_stickiness_matchers SQL_SKIP_STICKINESS_MATCHERS end
sql_slave_matchers()
click to toggle source
# File lib/active_record/connection_adapters/makara_abstract_adapter.rb, line 107 def sql_slave_matchers SQL_SLAVE_MATCHERS end
Protected Instance Methods
active_record_connection_for(config)
click to toggle source
# File lib/active_record/connection_adapters/makara_abstract_adapter.rb, line 182 def active_record_connection_for(config) raise NotImplementedError end
appropriate_connection(method_name, args) { |con| ... }
click to toggle source
Calls superclass method
Makara::Proxy#appropriate_connection
# File lib/active_record/connection_adapters/makara_abstract_adapter.rb, line 127 def appropriate_connection(method_name, args, &block) if needed_by_all?(method_name, args) handling_an_all_execution(method_name) do hijacked do # slave pool must run first. @slave_pool.send_to_all(nil, &block) # just yields to each con @master_pool.send_to_all(nil, &block) # just yields to each con end end else super(method_name, args) do |con| yield con end end end
coerce_query_to_sql_string(sql_or_arel)
click to toggle source
# File lib/active_record/connection_adapters/makara_abstract_adapter.rb, line 169 def coerce_query_to_sql_string(sql_or_arel) if sql_or_arel.respond_to?(:to_sql) sql_or_arel.to_sql else sql_or_arel.to_s end end
connection_for(config)
click to toggle source
# File lib/active_record/connection_adapters/makara_abstract_adapter.rb, line 177 def connection_for(config) config = Makara::ConfigParser.merge_and_resolve_default_url_config(config) active_record_connection_for(config) end
needed_by_all?(method_name, args)
click to toggle source
# File lib/active_record/connection_adapters/makara_abstract_adapter.rb, line 154 def needed_by_all?(method_name, args) sql = coerce_query_to_sql_string(args.first) return true if sql_all_matchers.any?{|m| sql =~ m } false end
needs_master?(method_name, args)
click to toggle source
# File lib/active_record/connection_adapters/makara_abstract_adapter.rb, line 161 def needs_master?(method_name, args) sql = coerce_query_to_sql_string(args.first) return true if sql_master_matchers.any?{|m| sql =~ m } return false if sql_slave_matchers.any?{|m| sql =~ m } true end
should_stick?(method_name, args)
click to toggle source
Calls superclass method
Makara::Proxy#should_stick?
# File lib/active_record/connection_adapters/makara_abstract_adapter.rb, line 147 def should_stick?(method_name, args) sql = coerce_query_to_sql_string(args.first) return false if sql_skip_stickiness_matchers.any?{|m| sql =~ m } super end