Sha256: f01ca972510d7babfe6fdea4fed1994da7b82ff3a1fd7c65156a380bdd4921a3
Contents?: true
Size: 857 Bytes
Versions: 1
Compression:
Stored size: 857 Bytes
Contents
require 'uri' require 'sequel' module Skalera module Services class Postgres SERVICE_NAME = 'postgres' def self.instance(database) if ENV['SKALERA_DB_URL'] url = ENV['SKALERA_DB_URL'] else postgres_config = Diplomat::Service.get(SERVICE_NAME) uri = URI('postgres:/') uri.host = postgres_config.Address uri.port = postgres_config.ServicePort uri.user = key('user') uri.password = key('password') uri.path = "/#{database}" url = uri.to_s end db = ::Sequel.connect(url) at_exit { db.disconnect } db rescue Diplomat::KeyNotFound STDERR.puts "ERROR: service not found: #{SERVICE_NAME}" end def self.key(key) Diplomat.get("postgres/#{key}") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
skalera-services-0.2.5 | lib/skalera/services/postgres.rb |