pushyd 0.24.1 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c0b26eba48301767a70e3cfaca254a849500f06
4
- data.tar.gz: 6133a4c4035b49738d644bc835f14d35cd261ac8
3
+ metadata.gz: 1bf480c7c62d3a53870416ec77b427dd66dd0576
4
+ data.tar.gz: 1de20b6c29e3aca9aef05a616bc28ae27f4a42d9
5
5
  SHA512:
6
- metadata.gz: 7acb3652db0038dc43b4a9653d2a7971a11e49db23af44e790908951d7fffa5f3970da6dde6f5b9b2dd7fb498bce1a0be26700e9fc1432c31d133962918d4b29
7
- data.tar.gz: 9c989ff2fa8316b514fea66b31585de530815858f7619f7f209c7311c3dd47daa73f60d2d18b611a64f1305fac194cc906cd26e0a5da97ce0d9e8d7839ab908a
6
+ metadata.gz: c3d64b444baa8cabd798e29933e214f3731a46439583014e35ded348d6e9f75a4132eb9d446b92aee14dcf310e8b1746f3dc4e2758374924fd6c11f0c246bfb2
7
+ data.tar.gz: d2e5425547396b6e048d9c264a13ed63d00ac965d92b71f6cdd77a591dce731fab720d6eb8d1de9e957c1d9888aab74dd7cd81a8ca9f9fe3d93a9fe8ce1a4af4
data/.gitignore CHANGED
@@ -8,3 +8,7 @@ DOC/
8
8
  .ruby-version
9
9
  local.yml
10
10
  /.idea
11
+
12
+ Gemfile.lock
13
+ .ruby-version
14
+ .ruby-gemset
data/bin/pushyd CHANGED
@@ -25,7 +25,7 @@ begin
25
25
 
26
26
  # Parse options and check compliance
27
27
  parser = OptionParser.new do |opts|
28
- opts.banner = "Usage: #{File.basename $PROGRAM_NAME} [options] start|stop"
28
+ opts.banner = "Usage: #{File.basename $PROGRAM_NAME} [options] run|start|stop"
29
29
  opts.on("-l", "--log LOGFILE") { |path| cmd_logfile = File.expand_path(path.to_s)}
30
30
  opts.on("-c", "--config CONFIGFILE") { |path| cmd_config = File.expand_path(path.to_s)}
31
31
  opts.on("-e", "--environment ENV") { |env| Conf.app_env = env }
@@ -56,9 +56,9 @@ puts "Environment \t #{Conf.app_env}"
56
56
  puts "Config files \t #{Conf.files}"
57
57
  puts "Started at \t #{Conf.app_started}"
58
58
  puts "Loging to file \t #{Conf[:log][:file]}" if Conf[:log].is_a? Enumerable
59
- puts "Process name \t #{Conf.generate(:process_name)}"
60
- puts "Newrelic \t #{Conf.feature?(:newrelic) || '-'}"
61
- puts "Rollbar \t #{Conf.feature?(:rollbar) || '-'}"
59
+ puts "Process name \t #{Conf.generate_process_name}"
60
+ puts "Newrelic \t #{Conf.feature_newrelic? || '-'}"
61
+ puts "Rollbar \t #{Conf.feature_rollbar? || '-'}"
62
62
  if cmd_dump
63
63
  puts
64
64
  puts Conf.dump
@@ -73,7 +73,7 @@ monitor: false,
73
73
  dir_mode: :normal,
74
74
  dir: '/tmp/'
75
75
  }
76
- Daemons.run_proc(Conf.generate(:process_name), run_options) do
76
+ Daemons.run_proc(Conf.generate_process_name, run_options) do
77
77
  # Load code
78
78
  Conf.prepare_newrelic
79
79
 
data/defaults.yml CHANGED
@@ -34,7 +34,14 @@ rollbar:
34
34
  # proxy_tests:
35
35
  # title: All proxy tests messages
36
36
  # topic: proxy
37
- # routes: "proxy.#"
37
+ # keys: proxy.#
38
+ # keys: proxy.key1, proxy.key2, proxy.key3
39
+ # keys:
40
+ # - proxy.key1
41
+ # - proxy.key2
42
+ # - proxy.key3
43
+ # keys: "proxy.#"
44
+ # keys: "proxy.#"
38
45
  # subscribe: false
39
46
  # #relay: http://requestb.in/1clzv7v1
40
47
 
@@ -90,7 +90,7 @@ module PushyDaemon
90
90
  headers = {
91
91
  content_type: :json,
92
92
  accept: :json,
93
- user_agent: BmcDaemonLib::Conf.generate(:user_agent),
93
+ user_agent: BmcDaemonLib::Conf.generate_user_agent,
94
94
  }
95
95
 
96
96
  # Compute: payload MD5, HMAC signature
data/lib/pushyd/proxy.rb CHANGED
@@ -18,7 +18,7 @@ module PushyDaemon
18
18
  # Init ASCII table
19
19
  @table = Terminal::Table.new
20
20
  @table.title = "Rules summary"
21
- @table.headings = ["rule", "topic", "route", "relay", "description", "status"]
21
+ @table.headings = ["rule", "topic", "> queue", "> relay", "routing key", "bind status"]
22
22
  @table.align_column(5, :right)
23
23
 
24
24
  # Prepare logger
@@ -82,23 +82,30 @@ module PushyDaemon
82
82
  end
83
83
  log_info "create_consumers: #{config_rules.keys.join(', ')}"
84
84
 
85
- # Subscribe for each and every rule/route
85
+ # Subscribe for each and every rule/key
86
86
  config_rules.each do |name, rule|
87
87
  rule[:name] = name
88
88
  @consumers << create_consumer(rule)
89
89
  end
90
90
  end
91
91
 
92
- # Subscribe to interesting topic/routes and bind a listenner
92
+ # Subscribe to interesting topic/key and bind a listenner
93
93
  def create_consumer rule
94
94
  # Check information
95
95
  rule_name = rule[:name].to_s
96
96
  rule_topic = rule[:topic].to_s
97
- rule_routes = rule[:routes].to_s.split(' ')
98
97
  rule_queue = sprintf('%s-%s', BmcDaemonLib::Conf.app_name, rule_name.gsub('_', '-'))
99
98
 
99
+ # Extract routing keys
100
+ if rule[:keys].is_a? Array
101
+ rule_keys = rule[:keys].map(&:to_s)
102
+ else
103
+ rule_keys = rule[:keys].to_s.split(',').map(&:strip)
104
+ end
105
+
106
+ # Check we have a topic and at least one routing key
100
107
  fail PushyDaemon::EndpointSubscribeContext, "rule [#{rule_name}] lacking topic" unless rule_topic
101
- fail PushyDaemon::EndpointSubscribeContext, "rule [#{rule_name}] lacking routes" if rule_routes.empty?
108
+ fail PushyDaemon::EndpointSubscribeContext, "rule [#{rule_name}] lacking keys" if rule_keys.empty?
102
109
 
103
110
  # Build a new consumer
104
111
  consumer = Consumer.new(@conn, rule_name, rule)
@@ -106,18 +113,23 @@ module PushyDaemon
106
113
  # Subscribe to my own queue
107
114
  consumer.subscribe_to_queue rule_queue, "rule:#{rule_name}"
108
115
 
109
- # Bind each route to exchange
110
- rule_routes.each do |route|
116
+ # Bind each key to exchange
117
+ rule_keys.each do |key|
111
118
  begin
112
- status = "> #{rule_queue}"
113
- consumer.listen_to rule_topic, route
114
- rescue BmcDaemonLib::MqConsumerTopicNotFound => e
115
- status = "! BIND FAILED"
116
- log_error "Proxy consumer: #{e.message}"
119
+ q = consumer.listen_to rule_topic, key
120
+ rescue BmcDaemonLib::MqConsumerTopicNotFound,
121
+ BmcDaemonLib::MqConsumerException => e
122
+ status = "FAILED: #{e.class} \n#{e.message}"
123
+ log_error "create_consumer [#{e.class}] #{e.message}"
124
+ rescue StandardError => e
125
+ status = "FAILED: #{e.message}"
126
+ log_error "create_consumer: #{e.message}"
127
+ else
128
+ status = "QUEUE #{q.object_id}"
117
129
  end
118
130
 
119
131
  # Add row to config table
120
- @table.add_row [rule_name, rule_topic, route, rule[:relay].to_s, rule[:title].to_s, status ]
132
+ @table.add_row [rule_name, rule_topic, rule_queue, rule[:relay].to_s, key, status ]
121
133
  end
122
134
 
123
135
  # Return consumer
data/pushyd.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  Gem::Specification.new do |spec|
3
3
  # Project version
4
- spec.version = "0.24.1"
4
+ spec.version = "0.25.0"
5
5
 
6
6
  # Project description
7
7
  spec.name = "pushyd"
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  # spec.add_development_dependency "pry"
29
29
 
30
30
  # Runtime dependencies
31
- spec.add_runtime_dependency "bmc-daemon-lib", "~> 0.6.0"
31
+ spec.add_runtime_dependency "bmc-daemon-lib", "= 0.9.2"
32
32
  spec.add_runtime_dependency "daemons"
33
33
  spec.add_runtime_dependency "json"
34
34
  spec.add_runtime_dependency "bunny", "~> 2.3"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pushyd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.1
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno MEDICI
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-16 00:00:00.000000000 Z
11
+ date: 2017-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: bmc-daemon-lib
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - '='
88
88
  - !ruby/object:Gem::Version
89
- version: 0.6.0
89
+ version: 0.9.2
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - '='
95
95
  - !ruby/object:Gem::Version
96
- version: 0.6.0
96
+ version: 0.9.2
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: daemons
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -217,7 +217,6 @@ files:
217
217
  - ".gitignore"
218
218
  - ".rubocop.yml"
219
219
  - Gemfile
220
- - Gemfile.lock
221
220
  - README.md
222
221
  - Rakefile
223
222
  - bin/pushyd
data/Gemfile.lock DELETED
@@ -1,101 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- pushyd (0.24.1)
5
- api-auth
6
- bmc-daemon-lib (~> 0.6.0)
7
- bunny (~> 2.3)
8
- daemons
9
- json
10
- newrelic_rpm
11
- rest-client (~> 1.8)
12
- rollbar
13
- terminal-table
14
-
15
- GEM
16
- remote: https://rubygems.org/
17
- specs:
18
- addressable (2.5.0)
19
- public_suffix (~> 2.0, >= 2.0.2)
20
- amq-protocol (2.0.1)
21
- api-auth (2.1.0)
22
- ast (2.3.0)
23
- bmc-daemon-lib (0.6.0)
24
- chamber (~> 2.9.1)
25
- bunny (2.6.2)
26
- amq-protocol (>= 2.0.1)
27
- chamber (2.9.1)
28
- hashie (~> 3.3)
29
- thor (~> 0.19.1)
30
- daemons (1.2.4)
31
- diff-lcs (1.2.5)
32
- domain_name (0.5.20161129)
33
- unf (>= 0.0.5, < 1.0.0)
34
- hashie (3.4.6)
35
- http (2.1.0)
36
- addressable (~> 2.3)
37
- http-cookie (~> 1.0)
38
- http-form_data (~> 1.0.1)
39
- http_parser.rb (~> 0.6.0)
40
- http-cookie (1.0.3)
41
- domain_name (~> 0.5)
42
- http-form_data (1.0.1)
43
- http_parser.rb (0.6.0)
44
- json (2.0.3)
45
- mime-types (2.99.3)
46
- multi_json (1.12.1)
47
- netrc (0.11.0)
48
- newrelic_rpm (3.17.2.327)
49
- parser (2.3.3.1)
50
- ast (~> 2.2)
51
- powerpack (0.1.1)
52
- public_suffix (2.0.5)
53
- rainbow (2.2.1)
54
- rake (12.0.0)
55
- rest-client (1.8.0)
56
- http-cookie (>= 1.0.2, < 2.0)
57
- mime-types (>= 1.16, < 3.0)
58
- netrc (~> 0.7)
59
- rollbar (2.14.0)
60
- multi_json
61
- rspec (3.5.0)
62
- rspec-core (~> 3.5.0)
63
- rspec-expectations (~> 3.5.0)
64
- rspec-mocks (~> 3.5.0)
65
- rspec-core (3.5.4)
66
- rspec-support (~> 3.5.0)
67
- rspec-expectations (3.5.0)
68
- diff-lcs (>= 1.2.0, < 2.0)
69
- rspec-support (~> 3.5.0)
70
- rspec-mocks (3.5.0)
71
- diff-lcs (>= 1.2.0, < 2.0)
72
- rspec-support (~> 3.5.0)
73
- rspec-support (3.5.0)
74
- rubocop (0.47.0)
75
- parser (>= 2.3.3.1, < 3.0)
76
- powerpack (~> 0.1)
77
- rainbow (>= 1.99.1, < 3.0)
78
- ruby-progressbar (~> 1.7)
79
- unicode-display_width (~> 1.0, >= 1.0.1)
80
- ruby-progressbar (1.8.1)
81
- terminal-table (1.7.3)
82
- unicode-display_width (~> 1.1.1)
83
- thor (0.19.4)
84
- unf (0.1.4)
85
- unf_ext
86
- unf_ext (0.0.7.2)
87
- unicode-display_width (1.1.3)
88
-
89
- PLATFORMS
90
- ruby
91
-
92
- DEPENDENCIES
93
- bundler (~> 1.6)
94
- http (~> 2.0)
95
- pushyd!
96
- rake
97
- rspec
98
- rubocop
99
-
100
- BUNDLED WITH
101
- 1.13.5