Sha256: adcf417023981e4ef7482f72c1fb6ad0d8330eb679d311eeb5288221c775107a
Contents?: true
Size: 807 Bytes
Versions: 4
Compression:
Stored size: 807 Bytes
Contents
# frozen_string_literal: true module Isolator class Configuration attr_accessor :disallow_per_thread_concurrent_transactions alias_method :disallow_per_thread_concurrent_transactions?, :disallow_per_thread_concurrent_transactions end class ConcurrentTransactionError < UnsafeOperationError MESSAGE = "You are trying to open a transaction while there is an open transation to another database." \ end Isolator.before_isolate do next unless Isolator.config.disallow_per_thread_concurrent_transactions? isolated_connections = Isolator.all_transactions.count do |conn_id, depth| depth >= Isolator.connection_threshold(conn_id) end next unless isolated_connections > 1 Isolator.notify(exception: ConcurrentTransactionError.new, backtrace: caller) end end
Version data entries
4 entries across 4 versions & 1 rubygems