bbk-app 1.1.1.276745 → 1.1.1.289665
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -4
- data/lib/bbk/app/dispatcher/message.rb +22 -0
- data/lib/bbk/app/dispatcher.rb +10 -3
- 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: 0a0e8837fd2b2114213ab0ddab182faa7e861cb8ab59b014ef38d15abc3a7a18
|
4
|
+
data.tar.gz: d922557b53b0c10914ebf52b54395d25121252e053346773fc507e2e054faf40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66814da21956e2fc4e2084df654235e2742ea194758778da6262911ddce8a62055da207c930f3b73f23bdd4e886419345bbbef7d82d403edc164c993dcba93a6
|
7
|
+
data.tar.gz: 0b03d263a0a70596718148933354a35c5a621a5cabd45bfac00d141a5e4be33804fe5dfe448ef92bba237ae8fe27f06c4d2493dbe2f04abcdf2f18886ff60b6f
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bbk-app (1.1.1.
|
4
|
+
bbk-app (1.1.1.289665)
|
5
5
|
activesupport (>= 6.0)
|
6
6
|
bbk-utils (> 1.0.1)
|
7
7
|
oj
|
@@ -33,7 +33,7 @@ GEM
|
|
33
33
|
bbk-utils (1.0.1.147183)
|
34
34
|
activesupport (>= 6.0)
|
35
35
|
russian
|
36
|
-
bigdecimal (3.1.
|
36
|
+
bigdecimal (3.1.9)
|
37
37
|
bunny (2.19.0)
|
38
38
|
amq-protocol (~> 2.3, >= 2.3.1)
|
39
39
|
sorted_set (~> 1, >= 1.0.2)
|
@@ -67,8 +67,9 @@ GEM
|
|
67
67
|
kwalify (0.7.2)
|
68
68
|
launchy (2.5.0)
|
69
69
|
addressable (~> 2.7)
|
70
|
+
mini_portile2 (2.8.8)
|
70
71
|
minitest (5.15.0)
|
71
|
-
oj (3.16.
|
72
|
+
oj (3.16.9)
|
72
73
|
bigdecimal (>= 3.0)
|
73
74
|
ostruct (>= 0.2)
|
74
75
|
ostruct (0.6.1)
|
@@ -143,7 +144,9 @@ GEM
|
|
143
144
|
sorted_set (1.0.3)
|
144
145
|
rbtree
|
145
146
|
set (~> 1.0)
|
146
|
-
sqlite3 (1.
|
147
|
+
sqlite3 (1.7.3)
|
148
|
+
mini_portile2 (~> 2.8.0)
|
149
|
+
sqlite3 (1.7.3-x86_64-linux)
|
147
150
|
terminal-table (3.0.2)
|
148
151
|
unicode-display_width (>= 1.1.1, < 3)
|
149
152
|
thread_safe (0.3.6)
|
@@ -161,6 +164,8 @@ GEM
|
|
161
164
|
|
162
165
|
PLATFORMS
|
163
166
|
ruby
|
167
|
+
x86_64-linux
|
168
|
+
x86_64-linux-musl
|
164
169
|
|
165
170
|
DEPENDENCIES
|
166
171
|
activerecord (~> 6.0)
|
@@ -12,6 +12,8 @@ module BBK
|
|
12
12
|
@delivery_info = delivery_info
|
13
13
|
@headers = headers.to_h.with_indifferent_access
|
14
14
|
@body = body
|
15
|
+
@acked = false
|
16
|
+
@nacked = false
|
15
17
|
end
|
16
18
|
|
17
19
|
# Lazy body parsing
|
@@ -24,11 +26,19 @@ module BBK
|
|
24
26
|
end
|
25
27
|
|
26
28
|
def ack(*args, answer: nil, **kwargs)
|
29
|
+
return if processed?
|
30
|
+
|
27
31
|
consumer.ack(self, *args, answer: answer, **kwargs)
|
32
|
+
@acked = true
|
33
|
+
nil
|
28
34
|
end
|
29
35
|
|
30
36
|
def nack(*args, error: nil, **kwargs)
|
37
|
+
return if processed?
|
38
|
+
|
31
39
|
consumer.nack(self, *args, error: error, **kwargs)
|
40
|
+
@nacked = true
|
41
|
+
nil
|
32
42
|
end
|
33
43
|
|
34
44
|
def message_id
|
@@ -62,6 +72,18 @@ module BBK
|
|
62
72
|
"#<#{self.class.name} @consumer=#{consumer.class.name}, @headers=#{headers.inspect}>"
|
63
73
|
end
|
64
74
|
|
75
|
+
def acked?
|
76
|
+
@acked
|
77
|
+
end
|
78
|
+
|
79
|
+
def nacked?
|
80
|
+
@nacked
|
81
|
+
end
|
82
|
+
|
83
|
+
def processed?
|
84
|
+
acked? || nacked?
|
85
|
+
end
|
86
|
+
|
65
87
|
end
|
66
88
|
end
|
67
89
|
end
|
data/lib/bbk/app/dispatcher.rb
CHANGED
@@ -56,6 +56,7 @@ module BBK
|
|
56
56
|
|
57
57
|
def register_publisher(publisher)
|
58
58
|
raise "Publisher support #{DEFAULT_PROTOCOL}" if publisher.protocols.include?(DEFAULT_PROTOCOL)
|
59
|
+
|
59
60
|
publishers << publisher
|
60
61
|
end
|
61
62
|
|
@@ -129,6 +130,10 @@ module BBK
|
|
129
130
|
# process one message and sending existed results messages
|
130
131
|
def process(message)
|
131
132
|
results = execute_message(message)
|
133
|
+
if message.respond_to?(:nacked?) && message.nacked?
|
134
|
+
logger.debug "Ignore sending results: message(#{message.headers[:message_id]}) nacked in processor"
|
135
|
+
return
|
136
|
+
end
|
132
137
|
logger.debug "There are #{results.count} results to send from #{message.headers[:message_id]}..."
|
133
138
|
send_results(message, results).value
|
134
139
|
rescue StandardError => e
|
@@ -145,7 +150,8 @@ module BBK
|
|
145
150
|
results = []
|
146
151
|
begin
|
147
152
|
is_unknown = @observer.instance_variable_get('@default') == processor
|
148
|
-
ActiveSupport::Notifications.instrument 'dispatcher.request.process', msg: message,
|
153
|
+
ActiveSupport::Notifications.instrument 'dispatcher.request.process', msg: message,
|
154
|
+
match: matched, unknown: is_unknown do
|
149
155
|
processor.call(message, results: results)
|
150
156
|
end
|
151
157
|
rescue StandardError => e
|
@@ -158,7 +164,8 @@ module BBK
|
|
158
164
|
end
|
159
165
|
[results].flatten
|
160
166
|
rescue StandardError => e
|
161
|
-
ActiveSupport::Notifications.instrument 'dispatcher.request.exception', msg: message,
|
167
|
+
ActiveSupport::Notifications.instrument 'dispatcher.request.exception', msg: message,
|
168
|
+
match: matched, processor: processor, exception: e
|
162
169
|
raise
|
163
170
|
end
|
164
171
|
|
@@ -184,7 +191,7 @@ module BBK
|
|
184
191
|
answers, sended_messages = results.partition { _1.route.domain == ANSWER_DOMAIN }
|
185
192
|
# allowed only one answer message
|
186
193
|
raise InvalidAnswersMessagesCountError.new("Get #{answers.size} on processing message with id=#{message_id}") if answers.size > 1
|
187
|
-
|
194
|
+
|
188
195
|
answer = answers.first
|
189
196
|
Concurrent::Promises.zip_futures(*sended_messages.map do |result|
|
190
197
|
publish_result(result)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bbk-app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.1.
|
4
|
+
version: 1.1.1.289665
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samoilenko Yuri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|