bbk-app 1.1.2.328669 → 1.1.3.335065

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
  SHA256:
3
- metadata.gz: 79991eea1d6be65a89731af55d6ac7430f55ab259fc6cc5f37a384ed8a4b8c83
4
- data.tar.gz: a4bec2b9ad18bb2471abb62652704938b6bf0bf00d56c4a24291a7e622d09dc7
3
+ metadata.gz: 6cdea79b7c72b3ee5dda38ac8d1091453efc32ca5b02609947aa8410935c08e2
4
+ data.tar.gz: 90b2a70fbe5e4e9d8327b2a3c99b27547bbbcbf240ef800101f3364afdeb56c6
5
5
  SHA512:
6
- metadata.gz: 285f47e5fabc4a798a247330e6f011c028952581f6708d77034304bb1d4081f150c40fcd510ae5df59712418c06e72687016919c48e349cb132c39733d4c923c
7
- data.tar.gz: 2e72e45341b288a0b774ac56d7ce71720eef995359796a67a234721f71958f6eaf5af1d5d9935185d60a85b8304e55f7f41c5916860b5000c9bd900820b8f7db
6
+ metadata.gz: 0ae86e986da874fb89cbf2dee340ddc3b79e0565e35bb0d9c02d3b4fb06ec1632ab5c94df0063c9339f2b672cf857ddadf75fab5331febd44ea5de394a162998
7
+ data.tar.gz: def70137bdcbf862088d2a9907b0dc38560b5bc4b2c8762c6e74703c25bc7e22ea79f365d466e26f78c15b3fbcd7a3f56dee113a80e2d31f42810bb0ce492fce
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bbk-app (1.1.2.328669)
4
+ bbk-app (1.1.3.335065)
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.2.3)
36
+ bigdecimal (3.3.1)
37
37
  bunny (2.19.0)
38
38
  amq-protocol (~> 2.3, >= 2.3.1)
39
39
  sorted_set (~> 1, >= 1.0.2)
@@ -69,7 +69,7 @@ GEM
69
69
  addressable (~> 2.7)
70
70
  mini_portile2 (2.8.8)
71
71
  minitest (5.15.0)
72
- oj (3.16.11)
72
+ oj (3.16.12)
73
73
  bigdecimal (>= 3.0)
74
74
  ostruct (>= 0.2)
75
75
  ostruct (0.6.3)
@@ -0,0 +1,49 @@
1
+ require 'bbk/app/dispatcher/message_stream'
2
+
3
+ module BBK
4
+ module App
5
+ class Dispatcher
6
+ class DirectStreamStrategy
7
+
8
+ def initialize(pool, logger:)
9
+ @pool = pool
10
+ @logger = logger
11
+ @stopped = false
12
+ end
13
+
14
+ def run(consumers, &block)
15
+ @block = block
16
+ @unblocker = Queue.new
17
+
18
+ consumers.each {|cons| cons.run(self) }
19
+ @pool.wait_for_termination(0)
20
+
21
+ begin
22
+ @pool.shutdown
23
+ rescue StandardError
24
+ nil
25
+ end
26
+ @pool.kill unless @pool.wait_for_termination(@stop_queue_timeout)
27
+ ensure
28
+ @unblocker.push(:ok)
29
+ end
30
+
31
+ def push(message)
32
+ @logger.debug "[#{self.class}] Consumed message #{message.headers}"
33
+ @pool.post(message, &@block) unless @stopped
34
+ end
35
+ alias << push
36
+
37
+ def stop(timeout = 5)
38
+ @stopped = true
39
+ @stop_queue_timeout = timeout
40
+
41
+ @pool.shutdown rescue nil
42
+ @unblocker.pop
43
+ end
44
+
45
+ end
46
+ end
47
+ end
48
+ end
49
+
@@ -40,7 +40,11 @@ module BBK
40
40
  @nacked = true
41
41
  nil
42
42
  end
43
-
43
+
44
+ def metadata
45
+ @metadata = payload.fetch(:metadata, {})
46
+ end
47
+
44
48
  def message_id
45
49
  raise NotImplementedError.new("#{self.class.name} does not implement #{__method__} method")
46
50
  end
@@ -3,6 +3,7 @@ require 'bbk/app/thread_pool'
3
3
  require 'bbk/app/dispatcher/message_stream'
4
4
  require 'bbk/app/dispatcher/message'
5
5
  require 'bbk/app/dispatcher/queue_stream_strategy'
6
+ require 'bbk/app/dispatcher/direct_stream_strategy'
6
7
  require 'bbk/app/dispatcher/result'
7
8
  require 'bbk/app/dispatcher/route'
8
9
  require 'bbk/utils/proxy_logger'
@@ -17,7 +17,8 @@ RSpec.shared_examples 'BBK::App::Dispatcher::Message' do
17
17
  }
18
18
  end
19
19
 
20
- let(:body) { JSON.generate(Hash[Random.rand(2..6).times.map { [SecureRandom.hex, SecureRandom.hex] }]) }
20
+ let(:metadata) { {m: 1} }
21
+ let(:body) { JSON.generate(Hash[Random.rand(2..6).times.map { [SecureRandom.hex, SecureRandom.hex] }].merge(metadata:)) }
21
22
  let(:payload) { JSON.parse(body) }
22
23
 
23
24
  describe 'Interface' do
@@ -26,6 +27,7 @@ RSpec.shared_examples 'BBK::App::Dispatcher::Message' do
26
27
  it { is_expected.to respond_to(:headers).with(0).argument }
27
28
  it { is_expected.to respond_to(:body).with(0).argument }
28
29
  it { is_expected.to respond_to(:payload).with(0).argument }
30
+ it { is_expected.to respond_to(:metadata).with(0).argument }
29
31
 
30
32
  it { is_expected.to respond_to(:ack).with_unlimited_arguments.with_keywords(:answer).with_any_keywords }
31
33
  it { is_expected.to respond_to(:nack).with_unlimited_arguments.with_keywords(:error).with_any_keywords }
@@ -46,6 +48,7 @@ RSpec.shared_examples 'BBK::App::Dispatcher::Message' do
46
48
  it { is_expected.to have_attributes(headers: include(headers)) }
47
49
  it { is_expected.to have_attributes(body: body) }
48
50
  it { is_expected.to have_attributes(payload: payload) }
51
+ it { is_expected.to have_attributes(metadata: metadata) }
49
52
 
50
53
  context 'with invalid body' do
51
54
  let(:body) { ']invalid_trash' }
@@ -1,7 +1,7 @@
1
1
  module BBK
2
2
  module App
3
3
 
4
- VERSION = '1.1.2'
4
+ VERSION = '1.1.3'
5
5
 
6
6
  end
7
7
  end
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.2.328669
4
+ version: 1.1.3.335065
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samoilenko Yuri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-09-29 00:00:00.000000000 Z
11
+ date: 2025-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -276,6 +276,7 @@ files:
276
276
  - bin/setup
277
277
  - lib/bbk/app.rb
278
278
  - lib/bbk/app/dispatcher.rb
279
+ - lib/bbk/app/dispatcher/direct_stream_strategy.rb
279
280
  - lib/bbk/app/dispatcher/message.rb
280
281
  - lib/bbk/app/dispatcher/message_stream.rb
281
282
  - lib/bbk/app/dispatcher/queue_stream_strategy.rb