Sha256: 16ba547d8d5e66bbf6abc65ef7c054b755c722b5de92fdb9946185eff62edf46

Contents?: true

Size: 377 Bytes

Versions: 6

Compression:

Stored size: 377 Bytes

Contents

# frozen_string_literal: true

require 'pg'
require 'connection_pool'

module TableSaw
  module Connection
    def self.with
      raise ArgumentError, 'requires a block' unless block_given?

      pool.with { |conn| yield conn }
    end

    def self.pool
      @pool ||= ConnectionPool.new(size: 2) { PG::Connection.new(TableSaw.configuration.connection) }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
table_saw-0.5.0 lib/table_saw/connection.rb
table_saw-0.4.0 lib/table_saw/connection.rb
table_saw-0.3.0 lib/table_saw/connection.rb
table_saw-0.2.1 lib/table_saw/connection.rb
table_saw-0.2.0 lib/table_saw/connection.rb
table_saw-0.1.0 lib/table_saw/connection.rb