Class: Dynflow::TransactionAdapters::ActiveRecord

Inherits:
Abstract
  • Object
show all
Defined in:
lib/dynflow/transaction_adapters/active_record.rb

Instance Method Summary collapse

Instance Method Details

#check(world) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/dynflow/transaction_adapters/active_record.rb', line 16

def check(world)
  # missing reader in ConnectionPool
  ar_pool_size = ::ActiveRecord::Base.connection_pool.instance_variable_get(:@size)
  if (world.options[:pool_size] / 2.0) > ar_pool_size
    world.logger.warn 'Consider increasing ActiveRecord::Base.connection_pool size, ' +
                          "it's #{ar_pool_size} but there is #{world.options[:pool_size]} " +
                          'threads in Dynflow pool.'
  end
end

#cleanupObject



12
13
14
# File 'lib/dynflow/transaction_adapters/active_record.rb', line 12

def cleanup
  ::ActiveRecord::Base.clear_active_connections!
end

#rollbackObject

Raises:

  • (::ActiveRecord::Rollback)


8
9
10
# File 'lib/dynflow/transaction_adapters/active_record.rb', line 8

def rollback
  raise ::ActiveRecord::Rollback
end

#transaction(&block) ⇒ Object



4
5
6
# File 'lib/dynflow/transaction_adapters/active_record.rb', line 4

def transaction(&block)
  ::ActiveRecord::Base.transaction(&block)
end