strum-esb 0.3.0 → 0.3.1
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 +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +29 -29
- data/lib/strum/esb/handler.rb +30 -23
- data/lib/strum/esb/message.rb +0 -4
- data/lib/strum/esb/version.rb +1 -1
- 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: 05de667ab7cd92e53407fee532ff3c7fe063330785aa845d56626da17e05228c
|
|
4
|
+
data.tar.gz: d65051ee4f0b11de008fda22a942758eac27379f54d09ea57a08672916ccf9a5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7244c70e6859e665f14524d9747ab5dbe51e2d13cc2e25f41782e6cc4264862ca60eba49a2f88d6292bd19283b8b42c6c1bbd071ea1d88b4e8aeaa5e3a5feed7
|
|
7
|
+
data.tar.gz: 6f846e8c287003b0d70262600b5836148be008c58debad027cf73ae860e51c08c820b267f74956e845a4595e87fbab726909f3005d54ca55befd118177fe603d
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
# Changelog
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.3.1]
|
|
6
|
+
### Removed
|
|
7
|
+
- removed `chain` support
|
|
8
|
+
### Added
|
|
9
|
+
- `bind_to` can take block for custom bindings
|
|
10
|
+
- `pipeline` and `pipeline_id` can be used as handler params
|
|
11
|
+
|
|
5
12
|
## [0.3.0] - 2022-03-14
|
|
6
13
|
### Added
|
|
7
14
|
- `content_type` option to send message by [@valeriia.kolisnyk]
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
strum-esb (0.3.
|
|
4
|
+
strum-esb (0.3.1)
|
|
5
5
|
bunny (~> 2.15)
|
|
6
6
|
connection_pool (~> 2.2.2)
|
|
7
7
|
dry-configurable (~> 0.12.1)
|
|
@@ -17,12 +17,12 @@ GEM
|
|
|
17
17
|
bunny (2.19.0)
|
|
18
18
|
amq-protocol (~> 2.3, >= 2.3.1)
|
|
19
19
|
sorted_set (~> 1, >= 1.0.2)
|
|
20
|
-
concurrent-ruby (1.1.
|
|
20
|
+
concurrent-ruby (1.1.10)
|
|
21
21
|
connection_pool (2.2.5)
|
|
22
|
-
debase (0.2.
|
|
23
|
-
debase-ruby_core_source (>= 0.10.
|
|
24
|
-
debase-ruby_core_source (0.10.
|
|
25
|
-
diff-lcs (1.
|
|
22
|
+
debase (0.2.5.beta2)
|
|
23
|
+
debase-ruby_core_source (>= 0.10.12)
|
|
24
|
+
debase-ruby_core_source (0.10.14)
|
|
25
|
+
diff-lcs (1.5.0)
|
|
26
26
|
dry-configurable (0.12.1)
|
|
27
27
|
concurrent-ruby (~> 1.0)
|
|
28
28
|
dry-core (~> 0.5, >= 0.5.0)
|
|
@@ -30,42 +30,42 @@ GEM
|
|
|
30
30
|
concurrent-ruby (~> 1.0)
|
|
31
31
|
dry-inflector (0.2.1)
|
|
32
32
|
json (2.6.1)
|
|
33
|
-
parallel (1.
|
|
34
|
-
parser (3.
|
|
33
|
+
parallel (1.22.1)
|
|
34
|
+
parser (3.1.1.0)
|
|
35
35
|
ast (~> 2.4.1)
|
|
36
|
-
rainbow (3.
|
|
36
|
+
rainbow (3.1.1)
|
|
37
37
|
rake (12.3.3)
|
|
38
38
|
rbtree (0.4.5)
|
|
39
|
-
regexp_parser (2.
|
|
39
|
+
regexp_parser (2.2.1)
|
|
40
40
|
rexml (3.2.5)
|
|
41
|
-
rspec (3.
|
|
42
|
-
rspec-core (~> 3.
|
|
43
|
-
rspec-expectations (~> 3.
|
|
44
|
-
rspec-mocks (~> 3.
|
|
45
|
-
rspec-core (3.
|
|
46
|
-
rspec-support (~> 3.
|
|
47
|
-
rspec-expectations (3.
|
|
41
|
+
rspec (3.11.0)
|
|
42
|
+
rspec-core (~> 3.11.0)
|
|
43
|
+
rspec-expectations (~> 3.11.0)
|
|
44
|
+
rspec-mocks (~> 3.11.0)
|
|
45
|
+
rspec-core (3.11.0)
|
|
46
|
+
rspec-support (~> 3.11.0)
|
|
47
|
+
rspec-expectations (3.11.0)
|
|
48
48
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
49
|
-
rspec-support (~> 3.
|
|
50
|
-
rspec-mocks (3.
|
|
49
|
+
rspec-support (~> 3.11.0)
|
|
50
|
+
rspec-mocks (3.11.0)
|
|
51
51
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
52
|
-
rspec-support (~> 3.
|
|
53
|
-
rspec-support (3.
|
|
54
|
-
rubocop (1.
|
|
52
|
+
rspec-support (~> 3.11.0)
|
|
53
|
+
rspec-support (3.11.0)
|
|
54
|
+
rubocop (1.26.1)
|
|
55
55
|
parallel (~> 1.10)
|
|
56
|
-
parser (>= 3.
|
|
56
|
+
parser (>= 3.1.0.0)
|
|
57
57
|
rainbow (>= 2.2.2, < 4.0)
|
|
58
58
|
regexp_parser (>= 1.8, < 3.0)
|
|
59
59
|
rexml
|
|
60
|
-
rubocop-ast (>= 1.
|
|
60
|
+
rubocop-ast (>= 1.16.0, < 2.0)
|
|
61
61
|
ruby-progressbar (~> 1.7)
|
|
62
62
|
unicode-display_width (>= 1.4.0, < 3.0)
|
|
63
|
-
rubocop-ast (1.
|
|
64
|
-
parser (>= 3.
|
|
63
|
+
rubocop-ast (1.16.0)
|
|
64
|
+
parser (>= 3.1.1.0)
|
|
65
65
|
rubocop-rspec (2.3.0)
|
|
66
66
|
rubocop (~> 1.0)
|
|
67
67
|
rubocop-ast (>= 1.1.0)
|
|
68
|
-
ruby-debug-ide (0.7.
|
|
68
|
+
ruby-debug-ide (0.7.3)
|
|
69
69
|
rake (>= 0.8.1)
|
|
70
70
|
ruby-progressbar (1.11.0)
|
|
71
71
|
serverengine (2.1.1)
|
|
@@ -82,14 +82,14 @@ GEM
|
|
|
82
82
|
rbtree
|
|
83
83
|
set (~> 1.0)
|
|
84
84
|
thor (1.2.1)
|
|
85
|
-
unicode-display_width (2.
|
|
85
|
+
unicode-display_width (2.1.0)
|
|
86
86
|
|
|
87
87
|
PLATFORMS
|
|
88
88
|
ruby
|
|
89
89
|
|
|
90
90
|
DEPENDENCIES
|
|
91
91
|
bundler (~> 2.1.4)
|
|
92
|
-
debase (~> 0.2.
|
|
92
|
+
debase (~> 0.2.5.beta2)
|
|
93
93
|
dry-inflector (~> 0.2.1)
|
|
94
94
|
rspec (~> 3)
|
|
95
95
|
rubocop (~> 1.15)
|
data/lib/strum/esb/handler.rb
CHANGED
|
@@ -17,18 +17,26 @@ module Strum
|
|
|
17
17
|
module ClassMethods
|
|
18
18
|
def bind_to(queue, message_type, message_binding, handler = nil)
|
|
19
19
|
bindings ||= (queue_opts && queue_opts[:bindings]) || {}
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
|
|
21
|
+
if block_given?
|
|
22
|
+
yield(bindings)
|
|
23
|
+
else
|
|
24
|
+
bindings[message_type] ||= []
|
|
25
|
+
bindings[message_type] << message_binding
|
|
26
|
+
end
|
|
27
|
+
|
|
22
28
|
from_queue queue, bindings: bindings
|
|
29
|
+
handlers[handler_key(message_type, message_binding)] = handler.to_s if handler
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def handler_key(message_type, message_binding)
|
|
23
33
|
_, *msg = Strum::Esb::Functions.public_send("#{message_type}_explain", message_binding)
|
|
24
|
-
@handlers ||= {}
|
|
25
34
|
params = msg.map{ |param| param&.to_s.gsub(/[^a-zA-Z0-9]/, "_")&.downcase }
|
|
26
|
-
|
|
27
|
-
@handlers[handler_key] = handler.to_s if handler
|
|
35
|
+
([message_type] + params).join("-")
|
|
28
36
|
end
|
|
29
37
|
|
|
30
38
|
def handlers
|
|
31
|
-
@handlers
|
|
39
|
+
@handlers ||= {}
|
|
32
40
|
end
|
|
33
41
|
|
|
34
42
|
def protobuf_service(service)
|
|
@@ -40,24 +48,23 @@ module Strum
|
|
|
40
48
|
end
|
|
41
49
|
end
|
|
42
50
|
|
|
51
|
+
def header(metadata, key)
|
|
52
|
+
(metadata[:headers] && metadata[:headers][key])&.to_s&.gsub(/[^a-zA-Z0-9]/, "_")&.downcase
|
|
53
|
+
end
|
|
54
|
+
|
|
43
55
|
def work_with_params(deserialized_msg, delivery_info, metadata)
|
|
44
56
|
Strum::Esb.config.before_handler_hooks.each { |hook| hook.call(deserialized_msg, delivery_info, metadata) }
|
|
45
57
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
info = header.call("info")
|
|
55
|
-
notice = header.call("notice")
|
|
56
|
-
Thread.current[:chain] = header.call("chain")
|
|
57
|
-
Thread.current[:pipeline] = header.call("pipeline")
|
|
58
|
-
Thread.current[:pipeline_id] = header.call("pipeline-id")
|
|
58
|
+
action = header(metadata, "action")
|
|
59
|
+
resource = header(metadata, "resource")
|
|
60
|
+
event = header(metadata, "event")
|
|
61
|
+
state = header(metadata, "state")
|
|
62
|
+
info = header(metadata, "info")
|
|
63
|
+
notice = header(metadata, "notice")
|
|
64
|
+
pipeline = Thread.current[:pipeline] = header(metadata, "pipeline")
|
|
65
|
+
pipeline_id = Thread.current[:pipeline_id] = header(metadata, "pipeline-id")
|
|
59
66
|
|
|
60
|
-
after_headers_hook
|
|
67
|
+
after_headers_hook(binding)
|
|
61
68
|
|
|
62
69
|
methods_names = if action
|
|
63
70
|
action_handler_methods(action, resource)
|
|
@@ -92,7 +99,7 @@ module Strum
|
|
|
92
99
|
method_params = method(method_name)
|
|
93
100
|
.parameters
|
|
94
101
|
.map { |param| _, param_name = param; param_name }
|
|
95
|
-
.then { |m| m & %I[action resource event state info
|
|
102
|
+
.then { |m| m & %I[action resource event state info pipeline pipeline_id] }
|
|
96
103
|
handler_params = method_params.each_with_object({}) { |i, res| res[i] = eval(i.to_s); }
|
|
97
104
|
logger.info("Handler #{method_name} found. Payload: #{payload}")
|
|
98
105
|
handler_params.count.positive? ? send(method_name, payload, handler_params) : send(method_name, payload)
|
|
@@ -106,7 +113,7 @@ module Strum
|
|
|
106
113
|
Strum::Esb.config.after_handler_hooks.each { |hook| hook.call(deserialized_msg, delivery_info, metadata, payload, error) }
|
|
107
114
|
end
|
|
108
115
|
|
|
109
|
-
def after_headers_hook; end
|
|
116
|
+
def after_headers_hook(bind); end
|
|
110
117
|
|
|
111
118
|
private
|
|
112
119
|
|
|
@@ -144,7 +151,7 @@ module Strum
|
|
|
144
151
|
result << "notice_#{notice}"
|
|
145
152
|
result << "notice_handler"
|
|
146
153
|
result
|
|
147
|
-
end
|
|
154
|
+
end
|
|
148
155
|
end
|
|
149
156
|
end
|
|
150
157
|
end
|
data/lib/strum/esb/message.rb
CHANGED
|
@@ -17,10 +17,6 @@ module Strum
|
|
|
17
17
|
properties[:headers] = {} unless properties[:headers].is_a?(Hash)
|
|
18
18
|
properties[:headers]["pipeline"] ||= Thread.current[:pipeline] if Thread.current[:pipeline]
|
|
19
19
|
properties[:headers]["pipeline-id"] ||= Thread.current[:pipeline_id] if Thread.current[:pipeline_id]
|
|
20
|
-
if (chain = Thread.current[:chain])
|
|
21
|
-
payload["chain"] ||= chain
|
|
22
|
-
headers["chain"] ||= chain
|
|
23
|
-
end
|
|
24
20
|
|
|
25
21
|
payload, valid_payload = Strum::Esb.config.serializer.serialize(payload, properties[:content_type])
|
|
26
22
|
unless valid_payload
|
data/lib/strum/esb/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: strum-esb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Serhiy Nazarov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-03-
|
|
11
|
+
date: 2022-03-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bunny
|