Module: ActiveRecordDeadlockHandler
- Defined in:
- lib/active_record_deadlock_handler.rb,
lib/active_record_deadlock_handler/backoff.rb,
lib/active_record_deadlock_handler/logging.rb,
lib/active_record_deadlock_handler/railtie.rb,
lib/active_record_deadlock_handler/version.rb,
lib/active_record_deadlock_handler/callbacks.rb,
lib/active_record_deadlock_handler/configuration.rb,
lib/active_record_deadlock_handler/retry_executor.rb,
lib/active_record_deadlock_handler/connection_adapter_patch.rb
Defined Under Namespace
Modules: Backoff, Callbacks, ConnectionAdapterPatch, Logging, RetryExecutor Classes: Configuration, Error, Railtie
Constant Summary collapse
- VERSION =
"0.1.1"
Class Method Summary collapse
- .configuration ⇒ Object
-
.configure ⇒ Object
Configure the gem.
-
.on_deadlock(&block) ⇒ Object
Register a callback invoked on every deadlock detection.
-
.reset_configuration! ⇒ Object
Resets configuration to defaults.
-
.with_retry(config: configuration, &block) ⇒ Object
Opt-in wrapper for use without Rails or when auto_patch is disabled.
Class Method Details
.configuration ⇒ Object
35 36 37 |
# File 'lib/active_record_deadlock_handler.rb', line 35 def configuration @configuration end |
.configure ⇒ Object
Configure the gem. Should be called once from an initializer.
28 29 30 31 32 33 |
# File 'lib/active_record_deadlock_handler.rb', line 28 def configure @configuration_mutex.synchronize do yield @configuration @configuration.validate! end end |
.on_deadlock(&block) ⇒ Object
Register a callback invoked on every deadlock detection.
45 46 47 |
# File 'lib/active_record_deadlock_handler.rb', line 45 def on_deadlock(&block) Callbacks.register(&block) end |
.reset_configuration! ⇒ Object
Resets configuration to defaults. Primarily useful in tests.
58 59 60 61 62 |
# File 'lib/active_record_deadlock_handler.rb', line 58 def reset_configuration! @configuration_mutex.synchronize do @configuration = Configuration.new end end |
.with_retry(config: configuration, &block) ⇒ Object
Opt-in wrapper for use without Rails or when auto_patch is disabled.
53 54 55 |
# File 'lib/active_record_deadlock_handler.rb', line 53 def with_retry(config: configuration, &block) RetryExecutor.run(config: config, &block) end |