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 +4 -4
- data/lib/consul_syncer/version.rb +1 -1
- data/lib/consul_syncer.rb +9 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b2bef9d0c04323f933176da717b088e7179d8c1654bad10a5c91d1e83f957fb
|
4
|
+
data.tar.gz: 25ecfe6ce76a967aefdb2d89fd82137664a418848587645a29fc1346fc95165a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42d34c44dc46d220efff7759e423aa3c2e62ed69e9a63e91fc342111f09ed14ba073798be9edb22c956c3e8007cb0746105c144dedac5bdb1cca0b2a27e94653
|
7
|
+
data.tar.gz: 32eeeb25cb89d0f20802abc6a61cf9437bc8f6c44158fc5c84999cca42eb0f4761bfeaf1a97a9062d9ceedadc7588186c3f82e6fe97688138ff4032f1ad04107
|
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
|
-
|
68
|
-
planned << [:register, [], expected]
|
67
|
+
planned << [:register, [], expected.merge(reason: "Updating #{description}")]
|
69
68
|
else
|
70
|
-
|
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
|
-
|
78
|
-
planned << [:deregister, [actual.fetch(:node), actual.fetch(:service_id)],
|
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
|
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.
|
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-
|
11
|
+
date: 2021-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|