consul_watcher 0.0.7 → 0.0.8

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: 10385ebf26cabbcdba284431f87c9220f38a25821abcf3376e0031bfc709c43e
4
- data.tar.gz: 27222ff9322f8a02c854f7b6c3690ea2962701a6bd0e47b7ed1541aacec34868
3
+ metadata.gz: 229edb91677150898553354f076ef07e1789d2adfe3b1a648a48d61778d474a2
4
+ data.tar.gz: 665d041e916790682cb375795302f448c55dcf74b5e411a851b2d7e5e3962fb3
5
5
  SHA512:
6
- metadata.gz: 0f42d44e314a742465176b6633c73c804b0a099f2cd37d9862c2ad38d19f068376de808162cf0b7a6012acff9b2b0a56f5bcdd22d13b3ba9b527f7537f5e2707
7
- data.tar.gz: 99b25756b89c30013daeef453756331eaaa87b61d57660c62c55926bd96af1d35b5b88745fafd59ef67532a7702f7c195e8b343ea77e52430019fa9c051c27c2
6
+ metadata.gz: e82d5923dab083db57f3d7c1a71641e8420ac0f52cd166d6acb06fc33b7149e3780c88b291996ff61f6e02982720800e36d7f4cbf7133826d1577ce5a3f05c03
7
+ data.tar.gz: 5ff07f4b9ff6b5d5644db74acb4d9b72b864bf38db98a1e1130cc4e3faa992eb8323569a7b6a64df1aa494de40e2dea92a777017c801abe0a0a5f7272f691fbc
data/Rakefile CHANGED
@@ -37,7 +37,7 @@ task up: [:start_deps] do
37
37
  end
38
38
 
39
39
  task :consume do
40
- ConsulWatcher::RakeHelper.config_rabbitmq
40
+ ConsulWatcher::RakeHelper.config_amqp
41
41
  puts 'Starting queue consumer'
42
42
  ConsulWatcher::RakeHelper.consumer_start
43
43
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.8
data/docker-entrypoint.sh CHANGED
@@ -8,6 +8,8 @@ echo "CLI_ARGS: \"${@}\""
8
8
  echo "WATCH_ARGS: \"${WATCH_ARGS}\""
9
9
  echo "WATCH_SCRIPT: \"${WATCH_SCRIPT}\""
10
10
  echo "CONSUL_HTTP_ADDR: \"${CONSUL_HTTP_ADDR}\""
11
+ export CONSUL_DC="$(curl ${CONSUL_HTTP_ADDR}/v1/agent/self | jq -r '.Config.Datacenter')"
12
+ echo "CONSUL_DC: \"${CONSUL_DC}\""
11
13
  echo "RUN_ONCE: \"${RUN_ONCE}\""
12
14
  if [[ ${#} != 0 ]]; then
13
15
  exec $@
@@ -9,12 +9,13 @@ require 'consul_watcher/filters'
9
9
  # Top Level module to run watch logic
10
10
  module ConsulWatcher
11
11
  def self.watch(config)
12
+ dc = ENV['CONSUL_DC']
12
13
  logger = Logger.new(STDOUT)
13
14
  logger.level = Logger::INFO
14
15
  assemble(config)
15
16
  current_watch_json = $stdin.read
16
17
  previous_watch_json = @storage.fetch
17
- changes = @watch_type.get_changes(previous_watch_json, current_watch_json)
18
+ changes = @watch_type.get_changes(previous_watch_json, current_watch_json, dc)
18
19
  changes.each do |change|
19
20
  @destination.send(change)
20
21
  end
@@ -12,32 +12,32 @@ module ConsulWatcher
12
12
 
13
13
  def initialize(destination_config)
14
14
  initialize_variables(destination_config)
15
- setup_rabbitmq
15
+ setup_amqp
16
16
  end
17
17
 
18
- def setup_rabbitmq
19
- @conn = Bunny.new(rabbitmq_opts)
18
+ def setup_amqp
19
+ @conn = Bunny.new(amqp_opts)
20
20
  @conn.start
21
21
  @ch = @conn.create_channel
22
22
  @ex = Bunny::Exchange.new(@ch,
23
23
  :topic,
24
- @rabbitmq_exchange,
24
+ @amqp_exchange,
25
25
  durable: true)
26
26
  end
27
27
 
28
- def rabbitmq_opts
28
+ def amqp_opts
29
29
  opts = {}
30
- opts[:vhost] = @rabbitmq_vhost
31
- opts[:username] = @rabbitmq_username
32
- opts[:password] = @rabbitmq_password
33
- if @rabbitmq_addresses
34
- opts[:addresses] = @rabbitmq_addresses
35
- elsif @rabbitmq_hosts
36
- opts[:hosts] = @rabbitmq_hosts
37
- opts[:port] = @rabbitmq_port if @rabbitmq_port
38
- elsif @rabbitmq_host
39
- opts[:host] = @rabbitmq_host
40
- opts[:port] = @rabbitmq_port if @rabbitmq_port
30
+ opts[:vhost] = @amqp_vhost
31
+ opts[:username] = @amqp_username
32
+ opts[:password] = @amqp_password
33
+ if @amqp_addresses
34
+ opts[:addresses] = @amqp_addresses
35
+ elsif @amqp_hosts
36
+ opts[:hosts] = @amqp_hosts
37
+ opts[:port] = @amqp_port if @amqp_port
38
+ elsif @amqp_host
39
+ opts[:host] = @amqp_host
40
+ opts[:port] = @amqp_port if @amqp_port
41
41
  end
42
42
  opts
43
43
  end
@@ -60,14 +60,14 @@ module ConsulWatcher
60
60
  logger.level = Logger::DEBUG
61
61
  {
62
62
  logger: logger,
63
- rabbitmq_host: nil,
64
- rabbitmq_hosts: nil,
65
- rabbitmq_addresses: nil,
66
- rabbitmq_port: '5672',
67
- rabbitmq_vhost: '/',
68
- rabbitmq_username: 'guest',
69
- rabbitmq_password: 'guest',
70
- rabbitmq_exchange: 'amq.topic'
63
+ amqp_host: nil,
64
+ amqp_hosts: nil,
65
+ amqp_addresses: nil,
66
+ amqp_port: '5672',
67
+ amqp_vhost: '/',
68
+ amqp_username: 'guest',
69
+ amqp_password: 'guest',
70
+ amqp_exchange: 'amq.topic'
71
71
  }
72
72
  end
73
73
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'base64'
4
4
  require 'flazm_ruby_helpers/class'
5
+ require 'diplomat'
5
6
 
6
7
  module ConsulWatcher
7
8
  module WatchType
@@ -13,11 +14,11 @@ module ConsulWatcher
13
14
  initialize_variables(watch_config)
14
15
  end
15
16
 
16
- def get_changes(previous_watch_json, current_watch_json)
17
+ def get_changes(previous_watch_json, current_watch_json, dc)
17
18
  json_diff = get_diff(previous_watch_json, current_watch_json)
18
19
 
19
20
  changes = json_diff.each.collect do |change|
20
- formatted_change = format_change('key', change)
21
+ formatted_change = format_change('key', change, dc)
21
22
  decode(formatted_change) if @decode_values
22
23
  formatted_change
23
24
  end.compact
@@ -52,10 +53,11 @@ module ConsulWatcher
52
53
  end.reduce({}, :merge)
53
54
  end
54
55
 
55
- def format_change(watch_type, change)
56
+ def format_change(watch_type, change, dc)
56
57
  old_value, new_value = change_values(change)
57
58
  {
58
59
  'id' => "consul_watcher.key.#{change[1][0].tr('/', '.')}",
60
+ 'consul_dc' => dc,
59
61
  'watch_type' => watch_type,
60
62
  'key_path' => change[1][0],
61
63
  'key_property' => change[1][1],
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: consul_watcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Fortman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-06 00:00:00.000000000 Z
11
+ date: 2019-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler