Sha256: e2633681b90a5b22c3d696cdc0ef932ff7afe10856c56cc1a4eda9e8677b22fc

Contents?: true

Size: 509 Bytes

Versions: 1

Compression:

Stored size: 509 Bytes

Contents

require 'connection_pool'

module PgConduit
  class Connections
    attr_reader :src_pool, :dest_pool

    def self.init_pool(params)
      ConnectionPool.new { PG::Connection.open(params) }
    end

    def initialize(source, destination)
      @src_pool   = self.class.init_pool source
      @dest_pool  = self.class.init_pool destination
    end

    def with_source
      @src_pool.with { |conn| yield conn }
    end

    def with_destination
      @dest_pool.with { |conn| yield conn }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pg_conduit-0.1.0 lib/pg_conduit/connections.rb