Class: LogicaCompiler::ActiveRecord::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/logica_compiler/active_record/runner.rb

Constant Summary collapse

DEFAULT_STATEMENT_TIMEOUT_MS =
3000

Instance Method Summary collapse

Constructor Details

#initialize(registry:, connection: nil, connection_pool: ::ActiveRecord::Base.connection_pool, dialect: nil) ⇒ Runner

Returns a new instance of Runner.



13
14
15
16
17
18
# File 'lib/logica_compiler/active_record/runner.rb', line 13

def initialize(registry:, connection: nil, connection_pool: ::ActiveRecord::Base.connection_pool, dialect: nil)
  @registry = registry
  @connection = connection
  @connection_pool = connection_pool
  @dialect = dialect
end

Instance Method Details

#exec(name, filters: {}, limit: nil, statement_timeout: DEFAULT_STATEMENT_TIMEOUT_MS) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/logica_compiler/active_record/runner.rb', line 20

def exec(name, filters: {}, limit: nil, statement_timeout: DEFAULT_STATEMENT_TIMEOUT_MS)
  return exec_with_connection(@connection, name, filters:, limit:, statement_timeout:) if @connection

  @connection_pool.with_connection do |conn|
    exec_with_connection(conn, name, filters:, limit:, statement_timeout:)
  end
end