skalera-services 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef15e869ed7232e36c6c51e7a39e13d4c0aad2e6
4
- data.tar.gz: 9eb782abef227999a1ed2cd9f24b87350d6df5c5
3
+ metadata.gz: 4eb2ac00691e718c26fa79f2cc816a8eca2d46b0
4
+ data.tar.gz: 52fb334e538f3f2c4a452c9701b0045554757ecf
5
5
  SHA512:
6
- metadata.gz: d45346dca1e3edf22d9563ba971357acb8ed7e95af1e9ccdab8049e4c3b6403c70fc86044a4be546ce235053458ca4440be7297137dcb2c4d7025a5c12a7400d
7
- data.tar.gz: 0032222ed36b2e2e96257d754432e365aec9804ccc8b006faac613db45d76e6eaafe2327135a03ef3ba6bbebbaee3c7fe560daec417bea45b5bffcbba5761b09
6
+ metadata.gz: 4ef642048d4efabecb726fcb2846b92edcd380ae35148cba38db560d1222ecb61fa3644f4904b969298379c92621a31a7556944768234b50269ca66db621cc32
7
+ data.tar.gz: f829b3ce5e65aa8233b302f4087eee1f1c0c5242db016a70d4b9009009c25ad46bb3e59398b8e647fdbb9c313428645b84525f8856df5ffd458134e1b5a7f044
@@ -9,7 +9,7 @@ module Skalera
9
9
  token = ENV['CONSUL_ACL_TOKEN']
10
10
  Diplomat.configuration.acl_token = token if token
11
11
 
12
- # force a lookup just to make a connection so we can bail out early if consul id down
12
+ # force a lookup just to make a connection so we can bail out early if consul is down
13
13
  Diplomat.get("services/#{service_name}")
14
14
  rescue Diplomat::KeyNotFound
15
15
  Diplomat.put("services/#{service_name}", service_name)
@@ -8,6 +8,8 @@ module Skalera
8
8
  host = extract(controllers, 'address')
9
9
  port = extract(controllers, 'port')
10
10
  [host['address'], port['port']]
11
+ rescue Diplomat::KeyNotFound
12
+ STDERR.puts "ERROR: key not found: controllers/#{controller_uuid}"
11
13
  end
12
14
 
13
15
  def self.extract(controllers, field)
@@ -3,8 +3,9 @@ require 'influxdb'
3
3
  module Skalera
4
4
  module Services
5
5
  class InfluxDB
6
+ SERVICE_NAME = 'influxdb-8086'
6
7
  def self.instance(database)
7
- influxdb_config = Diplomat::Service.get('influxdb-8086')
8
+ influxdb_config = Diplomat::Service.get(SERVICE_NAME)
8
9
 
9
10
  influxdb = ::InfluxDB::Client.new(database,
10
11
  host: influxdb_config.Address,
@@ -13,6 +14,8 @@ module Skalera
13
14
  password: key('password'))
14
15
  # does not need an at_exit, as the influx clients takes care of it
15
16
  influxdb
17
+ rescue Diplomat::KeyNotFound
18
+ STDERR.puts "ERROR: service not found: #{SERVICE_NAME}"
16
19
  end
17
20
 
18
21
  def self.key(key)
@@ -3,8 +3,9 @@ require 'sequel'
3
3
  module Skalera
4
4
  module Services
5
5
  class Postgres
6
+ SERVICE_NAME = 'postgres'
6
7
  def self.instance(database)
7
- postgres_config = Diplomat::Service.get('postgres')
8
+ postgres_config = Diplomat::Service.get(SERVICE_NAME)
8
9
 
9
10
  host = postgres_config.Address
10
11
  port = postgres_config.ServicePort
@@ -13,6 +14,8 @@ module Skalera
13
14
  db = ::Sequel.connect(url)
14
15
  at_exit { db.disconnect }
15
16
  db
17
+ rescue Diplomat::KeyNotFound
18
+ STDERR.puts "ERROR: service not found: #{SERVICE_NAME}"
16
19
  end
17
20
 
18
21
  def self.key(key)
@@ -3,12 +3,15 @@ require 'redis'
3
3
  module Skalera
4
4
  module Services
5
5
  class Redis
6
+ SERVICE_NAME = 'redis'
6
7
  def self.instance(database = 0)
7
- redis_config = Diplomat::Service.get('redis')
8
+ redis_config = Diplomat::Service.get(SERVICE_NAME)
8
9
 
9
10
  redis = ::Redis.new(url: url(password, redis_config.Address, redis_config.ServicePort, database))
10
11
  at_exit { redis.quit }
11
12
  redis
13
+ rescue Diplomat::KeyNotFound
14
+ STDERR.puts "ERROR: service not found: #{SERVICE_NAME}"
12
15
  end
13
16
 
14
17
  def self.url(password, host, port, database)
@@ -1,5 +1,5 @@
1
1
  module Skalera
2
2
  module Services
3
- VERSION = '0.2.3'
3
+ VERSION = '0.2.4'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skalera-services
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Englund
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-30 00:00:00.000000000 Z
11
+ date: 2016-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: airbrake