Sha256: 71e01181626ba318512566524131cfdacfeeb5c33b5f91d85e5c3f7098da218b
Contents?: true
Size: 1004 Bytes
Versions: 1
Compression:
Stored size: 1004 Bytes
Contents
require 'uri' require 'influxdb' module Skalera module Services class InfluxDB SERVICE_NAME = 'influxdb-8086' def self.instance(database) url = ENV['SKALERA_INFLUXDB_URL'] if url uri = URI(url) host = uri.host port = uri.port || '8086' user = uri.user password = uri.password else influxdb_config = Diplomat::Service.get(SERVICE_NAME) host = influxdb_config.Address port = influxdb_config.ServicePort user = key('user') password = key('password') end ::InfluxDB::Client.new(database, host: host, port: port, user: user, password: password) rescue URI::InvalidURIError => e STDERR.puts "ERROR: could not parse URL: #{e.message}" rescue Diplomat::KeyNotFound STDERR.puts "ERROR: service not found: #{SERVICE_NAME}" end def self.key(key) Diplomat.get("influxdb/#{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/influxdb.rb |