Sha256: 0a5d6e5158fa8df5ffd391eb4f1e0b2d2163b7491100a009b5c222dc9a31b15e

Contents?: true

Size: 520 Bytes

Versions: 5

Compression:

Stored size: 520 Bytes

Contents

require 'sequel'

module Skalera
  module Services
    class Postgres
      def self.instance(database)
        postgres_config = Diplomat::Service.get('postgres')

        host = postgres_config.Address
        port = postgres_config.ServicePort

        url = "postgres://#{key('user')}:#{key('password')}@#{host}:#{port}/#{database}"
        db = ::Sequel.connect(url)
        at_exit { db.disconnect }
        db
      end

      def self.key(key)
        Diplomat.get("postgres/#{key}")
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
skalera-services-0.2.3 lib/skalera/services/postgres.rb
skalera-services-0.2.2 lib/skalera/services/postgres.rb
skalera-services-0.2.1 lib/skalera/services/postgres.rb
skalera-services-0.2.0 lib/skalera/services/postgres.rb
skalera-services-0.1.0 lib/skalera/services/postgres.rb