jackhammer 1.3.4 → 1.5.0.rc
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.bundler-version +1 -0
- data/.dependabot/config.yml +5 -7
- data/.github/workflows/auto-approve.yml +3 -3
- data/.github/workflows/auto-merge.yml +19 -0
- data/.travis.yml +1 -0
- data/Gemfile.lock +62 -53
- data/README.md +39 -0
- data/Rakefile +1 -1
- data/jackhammer.gemspec +4 -2
- data/lib/jackhammer.rb +9 -0
- data/lib/jackhammer/cli.rb +1 -1
- data/lib/jackhammer/configuration.rb +4 -0
- data/lib/jackhammer/configuration_validator.rb +60 -0
- data/lib/jackhammer/middleware_collection.rb +29 -0
- data/lib/jackhammer/queue.rb +9 -1
- data/lib/jackhammer/queue_name.rb +1 -1
- data/lib/jackhammer/rake_task.rb +71 -0
- data/lib/jackhammer/topic.rb +5 -3
- data/lib/jackhammer/version.rb +1 -1
- metadata +18 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe3c95c59d65b18dc571d1ed7d3a20b64ee124573167059c931ebc88201453d8
|
4
|
+
data.tar.gz: 39f7e8b0a4fc0217074fd39c2fc118abbfd411a5f1500b27e419f1cd13d2c599
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2777a62d62fd0f1f0c6fba1e50734666378c124a1ff8b31b5daefc4c6f7ee5f29ab2dcc03eafe1baca09f84a6abe95624bc306b8da4918edd577354f4684c6fc
|
7
|
+
data.tar.gz: e173c65281312be2d6af359d9714de1a849d0bc9f43489a48b76b25dcf6ff9373b6e6c5fb0487de3c8aa041b86770d159d7be2ba04dff12bf489f4d1e19cd439
|
data/.bundler-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.21
|
data/.dependabot/config.yml
CHANGED
@@ -3,16 +3,14 @@ version: 1
|
|
3
3
|
update_configs:
|
4
4
|
- package_manager: "ruby:bundler"
|
5
5
|
directory: "/"
|
6
|
-
update_schedule: "
|
6
|
+
update_schedule: "daily"
|
7
7
|
commit_message:
|
8
8
|
prefix: "[dependabot]"
|
9
9
|
allowed_updates:
|
10
10
|
- match:
|
11
|
-
|
11
|
+
dependency_type: "all"
|
12
|
+
update_type: "security"
|
12
13
|
automerged_updates:
|
13
14
|
- match:
|
14
|
-
dependency_type: "
|
15
|
-
update_type: "
|
16
|
-
- match:
|
17
|
-
dependency_type: "production"
|
18
|
-
update_type: "all"
|
15
|
+
dependency_type: "all"
|
16
|
+
update_type: "security:patch"
|
@@ -1,7 +1,7 @@
|
|
1
|
-
# automatically approve PRs submitted by Dependabot
|
1
|
+
# automatically approve PRs submitted by Dependabot or Renofidev
|
2
2
|
# this will allow Dependabot to automatically merge dependency update PRs where CI passes
|
3
3
|
# from: https://github.com/hmarr/auto-approve-action
|
4
|
-
name: Auto approve
|
4
|
+
name: Auto approve dependency upgrades PRs
|
5
5
|
|
6
6
|
on:
|
7
7
|
pull_request
|
@@ -11,6 +11,6 @@ jobs:
|
|
11
11
|
runs-on: ubuntu-latest
|
12
12
|
steps:
|
13
13
|
- uses: hmarr/auto-approve-action@v2.0.0
|
14
|
-
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
|
14
|
+
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]' || github.actor == 'renofidev'
|
15
15
|
with:
|
16
16
|
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
name: automerge
|
2
|
+
on:
|
3
|
+
pull_request_review:
|
4
|
+
types:
|
5
|
+
- submitted
|
6
|
+
check_suite:
|
7
|
+
types:
|
8
|
+
- completed
|
9
|
+
status: {}
|
10
|
+
jobs:
|
11
|
+
automerge:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
steps:
|
14
|
+
- name: automerge
|
15
|
+
uses: "pascalgn/automerge-action@v0.12.0"
|
16
|
+
env:
|
17
|
+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
18
|
+
MERGE_METHOD: squash
|
19
|
+
MERGE_DELETE_BRANCH: true
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,77 +1,86 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
jackhammer (1.
|
5
|
-
bunny (~> 2.
|
4
|
+
jackhammer (1.5.0.rc)
|
5
|
+
bunny (~> 2.17)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (6.
|
11
|
-
activesupport (= 6.
|
12
|
-
activerecord (6.
|
13
|
-
activemodel (= 6.
|
14
|
-
activesupport (= 6.
|
15
|
-
activesupport (6.
|
10
|
+
activemodel (6.1.4)
|
11
|
+
activesupport (= 6.1.4)
|
12
|
+
activerecord (6.1.4)
|
13
|
+
activemodel (= 6.1.4)
|
14
|
+
activesupport (= 6.1.4)
|
15
|
+
activesupport (6.1.4)
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
-
i18n (>=
|
18
|
-
minitest (
|
19
|
-
tzinfo (~>
|
20
|
-
zeitwerk (~> 2.
|
21
|
-
amq-protocol (2.3.
|
22
|
-
ast (2.4.
|
23
|
-
bunny (2.
|
17
|
+
i18n (>= 1.6, < 2)
|
18
|
+
minitest (>= 5.1)
|
19
|
+
tzinfo (~> 2.0)
|
20
|
+
zeitwerk (~> 2.3)
|
21
|
+
amq-protocol (2.3.2)
|
22
|
+
ast (2.4.2)
|
23
|
+
bunny (2.19.0)
|
24
24
|
amq-protocol (~> 2.3, >= 2.3.1)
|
25
|
+
sorted_set (~> 1, >= 1.0.2)
|
25
26
|
bunny-mock (1.7.0)
|
26
27
|
bunny (>= 1.7)
|
27
28
|
byebug (11.1.3)
|
28
|
-
concurrent-ruby (1.1.
|
29
|
-
diff-lcs (1.
|
30
|
-
i18n (1.8.
|
29
|
+
concurrent-ruby (1.1.9)
|
30
|
+
diff-lcs (1.4.4)
|
31
|
+
i18n (1.8.10)
|
31
32
|
concurrent-ruby (~> 1.0)
|
32
|
-
minitest (5.14.
|
33
|
-
parallel (1.
|
34
|
-
parser (
|
35
|
-
ast (~> 2.4.
|
33
|
+
minitest (5.14.4)
|
34
|
+
parallel (1.20.1)
|
35
|
+
parser (3.0.1.1)
|
36
|
+
ast (~> 2.4.1)
|
36
37
|
rainbow (3.0.0)
|
37
|
-
rake (13.0.
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
rspec-
|
43
|
-
|
44
|
-
rspec-
|
45
|
-
rspec-
|
38
|
+
rake (13.0.4)
|
39
|
+
rbtree (0.4.4)
|
40
|
+
regexp_parser (2.1.1)
|
41
|
+
rexml (3.2.5)
|
42
|
+
rspec (3.10.0)
|
43
|
+
rspec-core (~> 3.10.0)
|
44
|
+
rspec-expectations (~> 3.10.0)
|
45
|
+
rspec-mocks (~> 3.10.0)
|
46
|
+
rspec-core (3.10.1)
|
47
|
+
rspec-support (~> 3.10.0)
|
48
|
+
rspec-expectations (3.10.1)
|
46
49
|
diff-lcs (>= 1.2.0, < 2.0)
|
47
|
-
rspec-support (~> 3.
|
48
|
-
rspec-mocks (3.
|
50
|
+
rspec-support (~> 3.10.0)
|
51
|
+
rspec-mocks (3.10.2)
|
49
52
|
diff-lcs (>= 1.2.0, < 2.0)
|
50
|
-
rspec-support (~> 3.
|
51
|
-
rspec-support (3.
|
52
|
-
rubocop (
|
53
|
+
rspec-support (~> 3.10.0)
|
54
|
+
rspec-support (3.10.2)
|
55
|
+
rubocop (1.18.3)
|
53
56
|
parallel (~> 1.10)
|
54
|
-
parser (>=
|
57
|
+
parser (>= 3.0.0.0)
|
55
58
|
rainbow (>= 2.2.2, < 4.0)
|
59
|
+
regexp_parser (>= 1.8, < 3.0)
|
56
60
|
rexml
|
57
|
-
rubocop-ast (>= 0.0
|
61
|
+
rubocop-ast (>= 1.7.0, < 2.0)
|
58
62
|
ruby-progressbar (~> 1.7)
|
59
|
-
unicode-display_width (>= 1.4.0, <
|
60
|
-
rubocop-ast (
|
61
|
-
parser (>=
|
62
|
-
rubocop-
|
63
|
-
rubocop (
|
64
|
-
rubocop-rspec (
|
65
|
-
rubocop (
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
63
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
64
|
+
rubocop-ast (1.7.0)
|
65
|
+
parser (>= 3.0.1.1)
|
66
|
+
rubocop-rake (0.6.0)
|
67
|
+
rubocop (~> 1.0)
|
68
|
+
rubocop-rspec (2.4.0)
|
69
|
+
rubocop (~> 1.0)
|
70
|
+
rubocop-ast (>= 1.1.0)
|
71
|
+
ruby-progressbar (1.11.0)
|
72
|
+
set (1.0.1)
|
73
|
+
sorted_set (1.0.3)
|
74
|
+
rbtree
|
75
|
+
set (~> 1.0)
|
76
|
+
tzinfo (2.0.4)
|
77
|
+
concurrent-ruby (~> 1.0)
|
78
|
+
unicode-display_width (2.0.0)
|
79
|
+
zeitwerk (2.4.2)
|
72
80
|
|
73
81
|
PLATFORMS
|
74
82
|
ruby
|
83
|
+
x86_64-linux
|
75
84
|
|
76
85
|
DEPENDENCIES
|
77
86
|
activerecord
|
@@ -82,8 +91,8 @@ DEPENDENCIES
|
|
82
91
|
rake
|
83
92
|
rspec
|
84
93
|
rubocop
|
85
|
-
rubocop-
|
94
|
+
rubocop-rake
|
86
95
|
rubocop-rspec
|
87
96
|
|
88
97
|
BUNDLED WITH
|
89
|
-
2.
|
98
|
+
2.2.15
|
data/README.md
CHANGED
@@ -90,6 +90,8 @@ module MyApp
|
|
90
90
|
config.publish_options = { mandatory: true, persistent: true }
|
91
91
|
config.yaml_config = "config/jackhammer.yml"
|
92
92
|
config.app_name = "my_app"
|
93
|
+
config.client_middleware.use MyClientMiddleware, some_arg: 1, other_arg: 2
|
94
|
+
config.server_middleware.use MyServerMiddleware
|
93
95
|
end
|
94
96
|
end
|
95
97
|
end
|
@@ -162,10 +164,47 @@ The intent of the options might not be obvious by looking at the name.
|
|
162
164
|
overridden by passing the same options as arguments in your code).
|
163
165
|
- **yaml_config** defines the file location of the Topic Exchange YAML
|
164
166
|
configuration file.
|
167
|
+
- **client_middleware** defines hooks that will be executed prior to publishing a message to a topic
|
168
|
+
- **server_middleware** defines hooks that will be executed prior to running the message handler
|
165
169
|
|
166
170
|
You can find defaults specified in the Jackhammer::Configuration class
|
167
171
|
constructor.
|
168
172
|
|
173
|
+
### Middleware
|
174
|
+
|
175
|
+
Middleware allows you to hook into message publishing (client) and handling (server).
|
176
|
+
|
177
|
+
It can be used to transform the passed in arguments before passing them along or to halt the execution completely.
|
178
|
+
The execution will be halted if the middleware instance does not yield.
|
179
|
+
|
180
|
+
#### Example client middleware
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
class MyClientMiddleware
|
184
|
+
def initialize(name)
|
185
|
+
@name = name
|
186
|
+
end
|
187
|
+
|
188
|
+
def call(message, options)
|
189
|
+
options[:headers][:hello] = @name
|
190
|
+
|
191
|
+
yield message, options
|
192
|
+
end
|
193
|
+
end
|
194
|
+
```
|
195
|
+
|
196
|
+
#### Example server middleware
|
197
|
+
|
198
|
+
```ruby
|
199
|
+
class MyServerMiddleware
|
200
|
+
def call(handler:, delivery_info:, properties:, content:)
|
201
|
+
puts "Hello, #{properties[:headers]['name']}!"
|
202
|
+
|
203
|
+
yield handler: handler, delivery_info: delivery_info, properties: properties, content: content
|
204
|
+
end
|
205
|
+
end
|
206
|
+
```
|
207
|
+
|
169
208
|
## Development
|
170
209
|
|
171
210
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/Rakefile
CHANGED
data/jackhammer.gemspec
CHANGED
@@ -22,7 +22,9 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
|
-
spec.
|
25
|
+
spec.required_ruby_version = '>= 2.6'
|
26
|
+
|
27
|
+
spec.add_dependency 'bunny', '~> 2.17'
|
26
28
|
|
27
29
|
spec.add_development_dependency 'activerecord'
|
28
30
|
spec.add_development_dependency 'bundler'
|
@@ -31,6 +33,6 @@ Gem::Specification.new do |spec|
|
|
31
33
|
spec.add_development_dependency 'rake'
|
32
34
|
spec.add_development_dependency 'rspec'
|
33
35
|
spec.add_development_dependency 'rubocop'
|
34
|
-
spec.add_development_dependency 'rubocop-
|
36
|
+
spec.add_development_dependency 'rubocop-rake'
|
35
37
|
spec.add_development_dependency 'rubocop-rspec'
|
36
38
|
end
|
data/lib/jackhammer.rb
CHANGED
@@ -7,6 +7,7 @@ require 'jackhammer/exceptions'
|
|
7
7
|
require 'jackhammer/log'
|
8
8
|
require 'jackhammer/configuration'
|
9
9
|
require 'jackhammer/message_receiver'
|
10
|
+
require 'jackhammer/middleware_collection'
|
10
11
|
require 'jackhammer/queue_name'
|
11
12
|
require 'jackhammer/queue'
|
12
13
|
require 'jackhammer/topic'
|
@@ -46,5 +47,13 @@ module Jackhammer
|
|
46
47
|
opts[:headers][:time] ||= time.iso8601
|
47
48
|
end
|
48
49
|
end
|
50
|
+
|
51
|
+
def client_middleware
|
52
|
+
configuration.client_middleware
|
53
|
+
end
|
54
|
+
|
55
|
+
def server_middleware
|
56
|
+
configuration.server_middleware
|
57
|
+
end
|
49
58
|
end
|
50
59
|
end
|
data/lib/jackhammer/cli.rb
CHANGED
@@ -2,6 +2,7 @@ module Jackhammer
|
|
2
2
|
class Configuration
|
3
3
|
attr_accessor(
|
4
4
|
:app_name,
|
5
|
+
:client_middleware,
|
5
6
|
:connection_options,
|
6
7
|
:connection_url,
|
7
8
|
:environment,
|
@@ -9,6 +10,7 @@ module Jackhammer
|
|
9
10
|
:logger,
|
10
11
|
:publish_options,
|
11
12
|
:server,
|
13
|
+
:server_middleware,
|
12
14
|
:yaml_config
|
13
15
|
)
|
14
16
|
|
@@ -20,6 +22,8 @@ module Jackhammer
|
|
20
22
|
@logger = Logger.new IO::NULL
|
21
23
|
@publish_options = { mandatory: true, persistent: true }
|
22
24
|
@yaml_config = './config/jackhammer.yml'
|
25
|
+
@client_middleware = MiddlewareCollection.new
|
26
|
+
@server_middleware = MiddlewareCollection.new
|
23
27
|
end
|
24
28
|
|
25
29
|
def self.instance
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Jackhammer
|
2
|
+
class ConfigurationValidator
|
3
|
+
attr_accessor :config_yaml, :environment, :errors
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@errors = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def validate
|
10
|
+
validate_environment_defined
|
11
|
+
return if errors.any?
|
12
|
+
validate_topic_exchange_defined
|
13
|
+
return if errors.any?
|
14
|
+
validate_queues_defined
|
15
|
+
return if errors.any?
|
16
|
+
validate_handlers_defined
|
17
|
+
end
|
18
|
+
|
19
|
+
def validate_environment_defined
|
20
|
+
return if config_yaml[environment]
|
21
|
+
|
22
|
+
add_error("Environment '#{environment}' is not defined")
|
23
|
+
end
|
24
|
+
|
25
|
+
def validate_topic_exchange_defined
|
26
|
+
return if config_yaml[environment].keys.any?
|
27
|
+
|
28
|
+
add_error("Environment '#{environment}' does not define a topic exchange")
|
29
|
+
end
|
30
|
+
|
31
|
+
def validate_queues_defined
|
32
|
+
topics = config_yaml[environment].keys
|
33
|
+
topics.each do |topic|
|
34
|
+
begin
|
35
|
+
next if config_yaml[environment][topic]['queues']
|
36
|
+
rescue StandardError
|
37
|
+
false
|
38
|
+
end
|
39
|
+
|
40
|
+
add_error("Topic '#{topic}' does not define any queues")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def validate_handlers_defined
|
45
|
+
config_yaml[environment].each do |exchange_name, exchange_config|
|
46
|
+
exchange_config['queues'].each do |qconfig|
|
47
|
+
Object.const_get(qconfig['handler'])
|
48
|
+
rescue NameError
|
49
|
+
add_error("Uninitialized constant #{qconfig['handler']}")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def add_error(str)
|
57
|
+
@errors << str
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Jackhammer
|
2
|
+
class MiddlewareCollection
|
3
|
+
def initialize
|
4
|
+
@entries = []
|
5
|
+
end
|
6
|
+
|
7
|
+
def use(klass, *args, **kwargs, &block)
|
8
|
+
@entries << Entry.new(klass: klass, args: args, kwargs: kwargs, block: block)
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(*args, **kwargs, &block)
|
12
|
+
call_chain = @entries.map(&:instantiate) + [block]
|
13
|
+
|
14
|
+
traverse = proc do |*procargs, **prockwargs|
|
15
|
+
call_chain.shift.call(*procargs, **prockwargs, &traverse) unless call_chain.empty?
|
16
|
+
end
|
17
|
+
|
18
|
+
traverse.call(*args, **kwargs)
|
19
|
+
end
|
20
|
+
|
21
|
+
Entry = Struct.new(:klass, :args, :kwargs, :block, keyword_init: true) do
|
22
|
+
def instantiate
|
23
|
+
return klass unless klass.respond_to?(:new)
|
24
|
+
|
25
|
+
klass.new(*args, **kwargs, &block)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/jackhammer/queue.rb
CHANGED
@@ -13,7 +13,15 @@ module Jackhammer
|
|
13
13
|
queue.subscribe do |delivery_info, properties, content|
|
14
14
|
Log.info { [delivery_info.inspect, properties.inspect].join(' || ') }
|
15
15
|
Log.debug { content }
|
16
|
-
|
16
|
+
|
17
|
+
Jackhammer.server_middleware.call(
|
18
|
+
handler: handler_object,
|
19
|
+
delivery_info: delivery_info,
|
20
|
+
properties: properties,
|
21
|
+
content: content
|
22
|
+
) do |**args|
|
23
|
+
args.fetch(:handler).call args.fetch(:content)
|
24
|
+
end
|
17
25
|
rescue StandardError => e
|
18
26
|
Log.error e
|
19
27
|
Jackhammer.configuration.exception_adapter.call e
|
@@ -7,7 +7,7 @@ module Jackhammer
|
|
7
7
|
def self.from_routing_key(routing_key)
|
8
8
|
fail(InvalidConfigError, "app_name must be set to determine queue_name from routing_key") if app_name.to_s.empty?
|
9
9
|
|
10
|
-
"#{app_name}_#{routing_key}_q".gsub(/[^\w]+/, '_').
|
10
|
+
"#{app_name}_#{routing_key}_q".gsub(/[^\w]+/, '_').squeeze('_')
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
require 'yaml'
|
4
|
+
require 'jackhammer/configuration_validator'
|
5
|
+
|
6
|
+
module Jackhammer
|
7
|
+
class RakeTask < ::Rake::TaskLib
|
8
|
+
# Name of test task. (default is :jackhammer)
|
9
|
+
attr_accessor :name
|
10
|
+
|
11
|
+
# File path of the configuration file. (default is ./config/jackhammer.yml)
|
12
|
+
attr_accessor :path
|
13
|
+
|
14
|
+
# Description of the test task. (default is 'Validate Jackhammer
|
15
|
+
# configuration')
|
16
|
+
attr_accessor :description
|
17
|
+
|
18
|
+
# Task prerequisites.
|
19
|
+
attr_accessor :deps
|
20
|
+
|
21
|
+
# Specifies the environment to inspect. (default is 'production')
|
22
|
+
attr_accessor :env
|
23
|
+
|
24
|
+
def initialize
|
25
|
+
super
|
26
|
+
@name = :jackhammer
|
27
|
+
@env = 'production'
|
28
|
+
@path = './config/jackhammer.yml'
|
29
|
+
@description = 'Validate Jackhammer configuration'
|
30
|
+
@deps = []
|
31
|
+
yield self if block_given?
|
32
|
+
if @name.is_a?(Hash)
|
33
|
+
@deps = @name.values.first
|
34
|
+
@name = @name.keys.first
|
35
|
+
end
|
36
|
+
define
|
37
|
+
end
|
38
|
+
|
39
|
+
def define
|
40
|
+
desc @description
|
41
|
+
task @name => Array(deps) do
|
42
|
+
validator = ConfigurationValidator.new
|
43
|
+
validator.config_yaml = YAML.safe_load(File.read(@path), [], [], true)
|
44
|
+
validator.environment = env
|
45
|
+
validator.validate
|
46
|
+
print_results validator.errors
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def print_results(errors)
|
53
|
+
puts "Jackhammer configuration #{path}\n"
|
54
|
+
if errors.any?
|
55
|
+
puts red("Problems identified: #{errors.size}\n")
|
56
|
+
errors.each { |error| puts red(error) }
|
57
|
+
exit 1
|
58
|
+
else
|
59
|
+
puts green('OK')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def red(text)
|
64
|
+
"\e[1;31m#{text}\e[0m"
|
65
|
+
end
|
66
|
+
|
67
|
+
def green(text)
|
68
|
+
"\e[1;32m#{text}\e[0m"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/lib/jackhammer/topic.rb
CHANGED
@@ -3,8 +3,8 @@ module Jackhammer
|
|
3
3
|
QUEUE_NAME_KEY = 'queue_name'.freeze
|
4
4
|
ROUTING_KEY_KEY = 'routing_key'.freeze
|
5
5
|
|
6
|
-
def initialize(name:,
|
7
|
-
@topic = Jackhammer.channel.topic
|
6
|
+
def initialize(name:, queue_config:, options: {})
|
7
|
+
@topic = Jackhammer.channel.topic(name, options)
|
8
8
|
@queue_config = normalize_queue_config(queue_config)
|
9
9
|
end
|
10
10
|
|
@@ -15,7 +15,9 @@ module Jackhammer
|
|
15
15
|
# We're expecting the client to specify at least the routing_key in options
|
16
16
|
# for each message published.
|
17
17
|
def publish(message, options)
|
18
|
-
|
18
|
+
Jackhammer.client_middleware.call(message, Jackhammer.publish_options(options)) do |msg, opts|
|
19
|
+
topic.publish msg, opts
|
20
|
+
end
|
19
21
|
end
|
20
22
|
|
21
23
|
def queues
|
data/lib/jackhammer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jackhammer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0.rc
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Serok
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.17'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.17'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name: rubocop-
|
126
|
+
name: rubocop-rake
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
@@ -150,7 +150,7 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
-
description:
|
153
|
+
description:
|
154
154
|
email:
|
155
155
|
- scott@renofi.com
|
156
156
|
executables:
|
@@ -158,12 +158,14 @@ executables:
|
|
158
158
|
extensions: []
|
159
159
|
extra_rdoc_files: []
|
160
160
|
files:
|
161
|
+
- ".bundler-version"
|
161
162
|
- ".dependabot/config.yml"
|
162
163
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
163
164
|
- ".github/ISSUE_TEMPLATE/config.yml"
|
164
165
|
- ".github/ISSUE_TEMPLATE/story.md"
|
165
166
|
- ".github/PULL_REQUEST_TEMPLATE.md"
|
166
167
|
- ".github/workflows/auto-approve.yml"
|
168
|
+
- ".github/workflows/auto-merge.yml"
|
167
169
|
- ".gitignore"
|
168
170
|
- ".rspec"
|
169
171
|
- ".travis.yml"
|
@@ -177,11 +179,14 @@ files:
|
|
177
179
|
- lib/jackhammer.rb
|
178
180
|
- lib/jackhammer/cli.rb
|
179
181
|
- lib/jackhammer/configuration.rb
|
182
|
+
- lib/jackhammer/configuration_validator.rb
|
180
183
|
- lib/jackhammer/exceptions.rb
|
181
184
|
- lib/jackhammer/log.rb
|
182
185
|
- lib/jackhammer/message_receiver.rb
|
186
|
+
- lib/jackhammer/middleware_collection.rb
|
183
187
|
- lib/jackhammer/queue.rb
|
184
188
|
- lib/jackhammer/queue_name.rb
|
189
|
+
- lib/jackhammer/rake_task.rb
|
185
190
|
- lib/jackhammer/server.rb
|
186
191
|
- lib/jackhammer/topic.rb
|
187
192
|
- lib/jackhammer/topic_manager.rb
|
@@ -192,7 +197,7 @@ licenses:
|
|
192
197
|
metadata:
|
193
198
|
homepage_uri: https://github.com/renofi/jackhammer
|
194
199
|
source_code_uri: https://github.com/renofi/jackhammer
|
195
|
-
post_install_message:
|
200
|
+
post_install_message:
|
196
201
|
rdoc_options: []
|
197
202
|
require_paths:
|
198
203
|
- lib
|
@@ -200,15 +205,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
200
205
|
requirements:
|
201
206
|
- - ">="
|
202
207
|
- !ruby/object:Gem::Version
|
203
|
-
version: '
|
208
|
+
version: '2.6'
|
204
209
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
210
|
requirements:
|
206
|
-
- - "
|
211
|
+
- - ">"
|
207
212
|
- !ruby/object:Gem::Version
|
208
|
-
version:
|
213
|
+
version: 1.3.1
|
209
214
|
requirements: []
|
210
|
-
rubygems_version: 3.
|
211
|
-
signing_key:
|
215
|
+
rubygems_version: 3.2.15
|
216
|
+
signing_key:
|
212
217
|
specification_version: 4
|
213
218
|
summary: Jackhammer is an opinionated facade over RabbitMQ Bunny
|
214
219
|
test_files: []
|