consul_syncer 1.2.0 → 1.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
  SHA256:
3
- metadata.gz: 875c3e3eee8a06872dde88a612d7dfb8ae33ac59377d441e54afa6585da787b7
4
- data.tar.gz: 4e1d1d3701fc464772745858109ff04260b0a8568e7ce8ad8eeab6ad6de26032
3
+ metadata.gz: 0b2bef9d0c04323f933176da717b088e7179d8c1654bad10a5c91d1e83f957fb
4
+ data.tar.gz: 25ecfe6ce76a967aefdb2d89fd82137664a418848587645a29fc1346fc95165a
5
5
  SHA512:
6
- metadata.gz: ae7f93e5464309a3ed828ba18e7f43bd8ff2ec8a111b513d225f598d2a84c6df80c480722d3f1545a7813c2a34fbf5de10083357432d6f3f9336bf4923a9f082
7
- data.tar.gz: 3cdeb2e0566669014aa37ae01cebcb453593e993cf9cee5a4155d26649fddb8f5ca38e179cd911979824c08a5fa98d23345bf441c5b2eb8e5937001263aedba0
6
+ metadata.gz: 42d34c44dc46d220efff7759e423aa3c2e62ed69e9a63e91fc342111f09ed14ba073798be9edb22c956c3e8007cb0746105c144dedac5bdb1cca0b2a27e94653
7
+ data.tar.gz: 32eeeb25cb89d0f20802abc6a61cf9437bc8f6c44158fc5c84999cca42eb0f4761bfeaf1a97a9062d9ceedadc7588186c3f82e6fe97688138ff4032f1ad04107
@@ -1,3 +1,3 @@
1
1
  class ConsulSyncer
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
data/lib/consul_syncer.rb CHANGED
@@ -64,31 +64,23 @@ class ConsulSyncer
64
64
  elsif remove_matching_service!(actual_definitions, expected, interesting)
65
65
  @logger.debug "Found #{description}"
66
66
  elsif remove_matching_service!(actual_definitions, expected, identifying)
67
- @logger.info "Updating #{description}"
68
- planned << [:register, [], expected]
67
+ planned << [:register, [], expected.merge(reason: "Updating #{description}")]
69
68
  else
70
- @logger.info "Adding #{description}"
71
- planned << [:register, [], expected]
69
+ planned << [:register, [], expected.merge(reason: "Adding #{description}")]
72
70
  end
73
71
  end
74
72
 
75
73
  # all definitions that are left did not match any expected definitions and are no longer needed
76
74
  actual_definitions.each do |actual|
77
- @logger.info "Removing #{actual.fetch(:service)} / #{actual.fetch(:service_id)} on #{actual.fetch(:node)} in Consul"
78
- planned << [:deregister, [actual.fetch(:node), actual.fetch(:service_id)], nil]
75
+ reason = "Removing #{actual.fetch(:service)} / #{actual.fetch(:service_id)} on #{actual.fetch(:node)} in Consul"
76
+ planned << [:deregister, [actual.fetch(:node), actual.fetch(:service_id)], {reason: reason}]
79
77
  end
80
78
 
81
79
  planned
82
80
  end
83
81
 
84
82
  def execute(planned)
85
- planned.each do |m, args, kwargs|
86
- if kwargs
87
- send m, *args, **kwargs
88
- else
89
- send m, *args
90
- end
91
- end
83
+ planned.each { |m, args, kwargs| send m, *args, **kwargs }
92
84
  end
93
85
 
94
86
  private
@@ -116,7 +108,8 @@ class ConsulSyncer
116
108
  end
117
109
 
118
110
  # creates or updates based on node and service
119
- def register(node:, service:, service_id:, service_address:, address:, tags:, port:)
111
+ def register(node:, service:, service_id:, service_address:, address:, tags:, port:, reason:)
112
+ @logger.info reason
120
113
  @consul.request(
121
114
  :put,
122
115
  '/v1/catalog/register',
@@ -132,7 +125,8 @@ class ConsulSyncer
132
125
  )
133
126
  end
134
127
 
135
- def deregister(node, service_id)
128
+ def deregister(node, service_id, reason:)
129
+ @logger.info reason
136
130
  @consul.request(
137
131
  :put,
138
132
  '/v1/catalog/deregister',
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: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-09 00:00:00.000000000 Z
11
+ date: 2021-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday