Sha256: 0ac3cae596de5b9897a8c8fe9fc8dc8c965ceb9ab7bc583475f39f88e63d0b20
Contents?: true
Size: 612 Bytes
Versions: 12
Compression:
Stored size: 612 Bytes
Contents
# frozen_string_literal: true module Isolator # ActiveSupport notifications listener # Used for ActiveRecord and ROM::SQL (when instrumentation is available) module ActiveSupportSubscriber START_PATTERN = %r{(\ABEGIN|\ASAVEPOINT)}xi FINISH_PATTERN = %r{(\ACOMMIT|\AROLLBACK|\ARELEASE|\AEND TRANSACTION)}xi def self.subscribe!(event) ::ActiveSupport::Notifications.subscribe(event) do |_name, _start, _finish, _id, query| Isolator.incr_transactions! if query[:sql] =~ START_PATTERN Isolator.decr_transactions! if query[:sql] =~ FINISH_PATTERN end end end end
Version data entries
12 entries across 12 versions & 1 rubygems