Sha256: a0bd56957e7dcaadc352e8b2dee2a223e8b6b2df31247f121a32f93e6d741b62

Contents?: true

Size: 825 Bytes

Versions: 1

Compression:

Stored size: 825 Bytes

Contents

# frozen_string_literal: true

module ActiveRecordDataLoader
  class Configuration
    attr_accessor :default_batch_size, :default_row_count, :logger, :statement_timeout, :connection_factory

    def initialize(
      default_batch_size: 100_000,
      default_row_count: 1,
      logger: nil,
      statement_timeout: "2min",
      connection_factory: -> { ::ActiveRecord::Base.connection }
    )
      @default_batch_size = default_batch_size
      @default_row_count = default_row_count
      @logger = logger || default_logger
      @statement_timeout = statement_timeout
      @connection_factory = connection_factory
    end

    private

    def default_logger
      if defined?(Rails) && Rails.respond_to?(:logger)
        Rails.logger
      else
        Logger.new($stdout, level: :info)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_record_data_loader-1.1.0 lib/active_record_data_loader/configuration.rb