README.md in isolator-0.11.0 vs README.md in isolator-1.0.0

- old
+ new

@@ -99,25 +99,56 @@ config.backtrace_filter = ->(backtrace) { backtrace.take(5) } # Define a custom ignorer class (must implement .prepare) # uses a row number based list from the .isolator_todo.yml file config.ignorer = Isolator::Ignorer + + # Turn on/off raising exceptions for simultaneous transactions to different databases + config.disallow_cross_database_transactions = false end ``` Isolator relies on [uniform_notifier][] to send custom notifications. **NOTE:** `uniform_notifier` should be installed separately (i.e., added to Gemfile). +### Callbacks + +Isolator different callbacks so you can inject your own logic or build custom extensions. + +```ruby +# This callback is called when Isolator enters the "danger zone"—a within-transaction context +Isolator.before_isolate do + puts "Entering a database transaction. Be careful!" +end + +# This callback is called when Isolator leaves the "danger zone" +Isolator.after_isolate do + puts "Leaving a database transaction. Everything is fine. Feel free to call slow HTTP APIs" +end + +# This callback is called every time a new transaction is open (root or nested) +Isolator.on_transaction_open do |event| + puts "New transaction from #{event[:connection_id]}. " \ + "Current depth: #{event[:depth]}" +end + +# This callback is called every time a transaction is completed +Isolator.on_transaction_close do |event| + puts "Transaction completed from #{event[:connection_id]}. " \ + "Current depth: #{event[:depth]}" +end +``` + ### Transactional tests support - Rails' baked-in [use_transactional_tests](https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html#class-ActiveRecord::FixtureSet-label-Transactional+Tests) - [database_cleaner](https://github.com/DatabaseCleaner/database_cleaner) gem. Make sure that you require isolator _after_ database_cleaner. ### Supported ORMs -- `ActiveRecord` >= 5.1 (4.2 likely till works, but we do not test against it anymore) +- `ActiveRecord` >= 6.0 (see older versions of Isolator for previous versions) - `ROM::SQL` (only if Active Support instrumentation extension is loaded) ### Adapters Isolator has a bunch of built-in adapters: @@ -156,10 +187,9 @@ ```ruby Isolator.adapters.sidekiq.ignore_if { Thread.current[:sidekiq_postpone] } ``` You can add as many _ignores_ as you want, the offense is registered iff all of them return false. - ### Using with sidekiq/testing If you require sidekiq/testing in your tests after isolator is required then it will blow away isolator's hooks, so you need to require isolator after requiring sidekiq/testing.