Sha256: 26d0df0cc9f1be1e9103f8566a5895d9d863b24291ba1707957758083bf47131

Contents?: true

Size: 571 Bytes

Versions: 2

Compression:

Stored size: 571 Bytes

Contents

import com.zaxxer.hikari.HikariDataSource

module Hucpa
  class ConnectionPool
    def initialize(options)
      @options = options
      @hikari_config = Configuration.new(options).to_hikari_config
    end

    def open
      datasource
    end

    def close
      datasource.close
    end

    def with_connection(&block)
      conn = datasource.connection

      block.call(conn)
    ensure
      conn.close
    end

    private

    attr_reader :hikari_config, :options

    def datasource
      @datasource ||= HikariDataSource.new(hikari_config)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hucpa-0.2.0-jruby lib/hucpa/connection_pool.rb
hucpa-0.1.0-jruby lib/hucpa/connection_pool.rb