skalera-services 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c758968620d43b811998ddda3e2792ef03560a70
4
- data.tar.gz: 3799661c72f7b7a0bc5648f03dae68ac1ba56030
3
+ metadata.gz: 30a722a2ad3ab8f3a35f1be649daa95562ab50bd
4
+ data.tar.gz: 9c71d1e0e63fa739cf74a3e9af1022c1b3cca1b8
5
5
  SHA512:
6
- metadata.gz: dce29c6b934aea5ae3812ac0268de1d905daa090ca5ec525461bc49b9dd10df55b6471bc12ea9e8ee9619013fe0d1e2dd7eac0ceaa80e9e9bbed327e875f8909
7
- data.tar.gz: 99cfe15a74c6dc3c3004d0c7c259dc5ca849ca30622413d53626d06ac6599d6712d13282b3d613855ceb8c151a9a0c75cf29f7a7d5b7a30ce35f0c31885cbe33
6
+ metadata.gz: c9f724236ef316e4649dba08c0a41b05b3d400cffe9db2ea11357823d3dd252c1cb8c57923272457ab4bcbe232fb49eb0b427aeb8197f93b3cd5ba7e6adb1b17
7
+ data.tar.gz: 3c7664f866fe4a18e0a5282264355edcf883765b5da6b19412920841bc2737db76d0a18504c7569370a36c76d5dceb12829339861cb66d8ed43273bb7dacbcf7
@@ -0,0 +1,28 @@
1
+ require 'diplomat'
2
+
3
+ module Skalera
4
+ module Services
5
+ class Controllers
6
+ def self.for(controller_uuid)
7
+ controllers = Diplomat::Kv.get("controllers/#{controller_uuid}", recurse: true)
8
+ host = extract(controllers, 'address')
9
+ port = extract(controllers, 'port')
10
+ [host['address'], port['port']]
11
+ end
12
+
13
+ def self.extract(controllers, field)
14
+ result = {}
15
+ controllers.select { |c| c[:key].match(%r{/#{field}}) }.each do |hash|
16
+ host = hash[:key].sub(%r{controllers/}, '').split('/')[1]
17
+ result[host] = hash[:value]
18
+ end
19
+ result
20
+ end
21
+
22
+ def self.add(controller_uuid, host, port)
23
+ Diplomat::Kv.put("controllers/#{controller_uuid}/address", host)
24
+ Diplomat::Kv.put("controllers/#{controller_uuid}/port", port)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,5 +1,5 @@
1
1
  module Skalera
2
2
  module Services
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
4
4
  end
5
5
  end
@@ -1,6 +1,7 @@
1
1
  require 'skalera/services/airbrake'
2
2
  require 'skalera/services/consul'
3
3
  require 'skalera/services/credentials'
4
+ require 'skalera/services/controllers'
4
5
  require 'skalera/services/errbit'
5
6
  require 'skalera/services/influxdb'
6
7
  require 'skalera/services/postgres'
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.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Englund
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-30 00:00:00.000000000 Z
11
+ date: 2015-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: airbrake
@@ -243,6 +243,7 @@ files:
243
243
  - lib/skalera/services.rb
244
244
  - lib/skalera/services/airbrake.rb
245
245
  - lib/skalera/services/consul.rb
246
+ - lib/skalera/services/controllers.rb
246
247
  - lib/skalera/services/credentials.rb
247
248
  - lib/skalera/services/errbit.rb
248
249
  - lib/skalera/services/influxdb.rb