consul_syncer 0.1.1 → 0.2.0

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: 3908993bf71987872f909d0f2ff621b919a4a6d7
4
- data.tar.gz: d87538b7997969af59a32e1da624834606050035
3
+ metadata.gz: 84bf7af4ae453bd70d421f22046be75e50430646
4
+ data.tar.gz: 88a811c044da4d8593ee992d2539164900fc6c84
5
5
  SHA512:
6
- metadata.gz: 983c23b1e59daf6c49260ec4b7c97192defb210081dbbc23552dbe1e3d73c5944663d3ad4a39a17d9f1bc1a61db390413a7d4525d3a4336f287acf9d2523b39d
7
- data.tar.gz: 7482606c0946bedb53ec7ec20039c9acea171fadf1b67dae2c9307f86ad30509b4171ebdfe7830b1efe72d484c83895c5ffb00753082a150fefd91e7ee27842c
6
+ metadata.gz: 09009163e3d55da5f45d4ec94f12e77aa0e6bf5203cec8bbe33c6bb029da76c96c2eadc8cf61ec77ce8e4ed012921d7001af7f9cb2c68ee374cad169b1f289a6
7
+ data.tar.gz: 1de658780985b5e9424b6498e6d1ff2214769606a3c079c68bef241c672f7f636ec6db588772a7127626418666ca12c7f2ac5e3b670caaa3b378f169c4afde8d
data/lib/consul_syncer.rb CHANGED
@@ -34,16 +34,17 @@ class ConsulSyncer
34
34
  address: consul_endpoint.ip,
35
35
  service: consul_endpoint.name,
36
36
  service_id: consul_endpoint.service_id,
37
+ service_address: consul_endpoint.service_address,
37
38
  tags: consul_endpoint.tags.sort,
38
39
  port: consul_endpoint.port
39
40
  }
40
41
  end
41
42
 
42
- identifying = [:node, :service]
43
- interesting = [*identifying, :address, :tags, :port]
43
+ identifying = [:node, :service_id]
44
+ interesting = [*identifying, :service, :service_address, :address, :tags, :port]
44
45
 
45
46
  expected_definitions.each do |expected|
46
- description = "#{expected.fetch(:service)} on #{expected.fetch(:node)} in Consul"
47
+ description = "#{expected.fetch(:service)} / #{expected.fetch(:service_id)} on #{expected.fetch(:node)} in Consul"
47
48
 
48
49
  if remove_matching_service!(actual_definitions, expected, interesting)
49
50
  @logger.info "Found #{description}"
@@ -60,7 +61,7 @@ class ConsulSyncer
60
61
 
61
62
  # all definitions that are left did not match any expected definitions and are no longer needed
62
63
  actual_definitions.each do |actual|
63
- @logger.info "Removing #{actual.fetch(:service)} on #{actual.fetch(:node)} in Consul"
64
+ @logger.info "Removing #{actual.fetch(:service)} / #{actual.fetch(:service_id)} on #{actual.fetch(:node)} in Consul"
64
65
  modified += 1
65
66
  deregister actual.fetch(:node), actual.fetch(:service_id)
66
67
  end
@@ -93,14 +94,16 @@ class ConsulSyncer
93
94
  end
94
95
 
95
96
  # creates or updates based on node and service
96
- def register(node:, service:, address:, tags:, port:)
97
+ def register(node:, service:, service_id:, service_address:, address:, tags:, port:)
97
98
  @consul.request(
98
99
  :put,
99
100
  '/v1/catalog/register',
100
101
  Node: node,
101
102
  Address: address,
102
103
  Service: {
104
+ ID: service_id,
103
105
  Service: service,
106
+ Address: service_address,
104
107
  Tags: tags,
105
108
  Port: port
106
109
  }
@@ -13,6 +13,10 @@ class ConsulSyncer
13
13
  @hash.fetch('Service').fetch('ID')
14
14
  end
15
15
 
16
+ def service_address
17
+ @hash.fetch('Service').fetch('Address')
18
+ end
19
+
16
20
  def node
17
21
  @hash.fetch('Node').fetch('Node')
18
22
  end
@@ -1,3 +1,3 @@
1
1
  class ConsulSyncer
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: consul_syncer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-14 00:00:00.000000000 Z
11
+ date: 2017-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday