Sha256: 213e9ae6c6f756e1086c1be429069530233a792b88f9cd35b58a88a25898190e

Contents?: true

Size: 740 Bytes

Versions: 4

Compression:

Stored size: 740 Bytes

Contents

module PgBouncerHero
  class Connection

    def initialize(host, port, user, password, dbname)
      @host = host
      @port = port
      @user = user
      @password = password
      @dbname = dbname
      @timeout = ENV["PGBOUNCERHERO_TIMEOUT"] || 5
    end

    def connection
      @connection ||= begin
         begin
          PG.connect(
            host: @host,
            port: @port,
            user: @user,
            password: @password,
            dbname: @dbname,
            connect_timeout: @timeout
          )
        rescue Exception => e
          Rails.logger.error("[PGBouncerHero] Host:#{@host} | Database Name:#{@dbname} | Timeout: #{@timeout}s => #{e}")
          nil
        end
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pgbouncerhero-2.0.0 lib/pgbouncerhero/connection.rb
pgbouncerhero-1.0.3 lib/pgbouncerhero/connection.rb
pgbouncerhero-1.0.1 lib/pgbouncerhero/connection.rb
pgbouncerhero-1.0.0 lib/pgbouncerhero/connection.rb