Class: ActiveRecord::ConnectionAdapters::JanusTrilogyAdapter
- Inherits:
-
TrilogyAdapter
- Object
- TrilogyAdapter
- ActiveRecord::ConnectionAdapters::JanusTrilogyAdapter
- Defined in:
- lib/janus-ar/active_record/connection_adapters/janus_trilogy_adapter.rb
Constant Summary collapse
- FOUND_ROWS =
'FOUND_ROWS'
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
Instance Method Summary collapse
- #clear_cache! ⇒ Object
- #connect! ⇒ Object
- #disconnect! ⇒ Object
- #execute(sql) ⇒ Object
- #execute_and_free(sql, name = nil, async: false) ⇒ Object
-
#initialize(*args) ⇒ JanusTrilogyAdapter
constructor
A new instance of JanusTrilogyAdapter.
- #raw_execute(sql, name, async: false, allow_retry: false, materialize_transactions: true) ⇒ Object
- #reconnect! ⇒ Object
- #replica_connection ⇒ Object
- #with_connection(_args = {}) ⇒ Object
Constructor Details
#initialize(*args) ⇒ JanusTrilogyAdapter
Returns a new instance of JanusTrilogyAdapter.
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/janus-ar/active_record/connection_adapters/janus_trilogy_adapter.rb', line 38 def initialize(*args) args[0][:janus]['replica']['database'] = args[0][:database] args[0][:janus]['primary']['database'] = args[0][:database] @replica_config = args[0][:janus]['replica'].symbolize_keys args[0] = args[0][:janus]['primary'].symbolize_keys super(*args) @connection_parameters ||= args[0] update_config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
28 29 30 |
# File 'lib/janus-ar/active_record/connection_adapters/janus_trilogy_adapter.rb', line 28 def config @config end |
Class Method Details
.dbconsole(config, options = {}) ⇒ Object
31 32 33 34 35 |
# File 'lib/janus-ar/active_record/connection_adapters/janus_trilogy_adapter.rb', line 31 def dbconsole(config, = {}) connection_config = Janus::DbConsoleConfig.new(config) super(connection_config, ) end |
Instance Method Details
#clear_cache! ⇒ Object
111 112 113 114 |
# File 'lib/janus-ar/active_record/connection_adapters/janus_trilogy_adapter.rb', line 111 def clear_cache!(...) replica_connection.clear_cache!(...) super end |
#connect! ⇒ Object
96 97 98 99 |
# File 'lib/janus-ar/active_record/connection_adapters/janus_trilogy_adapter.rb', line 96 def connect!(...) replica_connection.connect!(...) super end |
#disconnect! ⇒ Object
106 107 108 109 |
# File 'lib/janus-ar/active_record/connection_adapters/janus_trilogy_adapter.rb', line 106 def disconnect!(...) replica_connection.disconnect!(...) super end |
#execute(sql) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/janus-ar/active_record/connection_adapters/janus_trilogy_adapter.rb', line 64 def execute(sql) case where_to_send?(sql) when :all send_to_replica(sql, connection: :all, method: :execute) super(sql) when :replica send_to_replica(sql, connection: :replica, method: :execute) else Janus::Context.stick_to_primary if write_query?(sql) Janus::Context.used_connection(:primary) super(sql) end end |
#execute_and_free(sql, name = nil, async: false) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/janus-ar/active_record/connection_adapters/janus_trilogy_adapter.rb', line 78 def execute_and_free(sql, name = nil, async: false) case where_to_send?(sql) when :all send_to_replica(sql, connection: :all, method: :execute) super(sql, name, async:) when :replica send_to_replica(sql, connection: :replica, method: :execute) else Janus::Context.stick_to_primary if write_query?(sql) Janus::Context.used_connection(:primary) super(sql, name, async:) end end |
#raw_execute(sql, name, async: false, allow_retry: false, materialize_transactions: true) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/janus-ar/active_record/connection_adapters/janus_trilogy_adapter.rb', line 50 def raw_execute(sql, name, async: false, allow_retry: false, materialize_transactions: true) case where_to_send?(sql) when :all send_to_replica(sql, connection: :all, method: :execute) super when :replica send_to_replica(sql, connection: :replica, method: :execute) else Janus::Context.stick_to_primary if write_query?(sql) Janus::Context.used_connection(:primary) super end end |
#reconnect! ⇒ Object
101 102 103 104 |
# File 'lib/janus-ar/active_record/connection_adapters/janus_trilogy_adapter.rb', line 101 def reconnect!(...) replica_connection.reconnect!(...) super end |
#replica_connection ⇒ Object
116 117 118 |
# File 'lib/janus-ar/active_record/connection_adapters/janus_trilogy_adapter.rb', line 116 def replica_connection @replica_connection ||= ActiveRecord::ConnectionAdapters::TrilogyAdapter.new(@replica_config) end |
#with_connection(_args = {}) ⇒ Object
92 93 94 |
# File 'lib/janus-ar/active_record/connection_adapters/janus_trilogy_adapter.rb', line 92 def with_connection(_args = {}) self end |