sbmt-outbox 6.15.0 → 6.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -0
- data/lib/sbmt/outbox/engine.rb +1 -0
- data/lib/sbmt/outbox/v2/poller.rb +4 -3
- data/lib/sbmt/outbox/version.rb +1 -1
- data/lib/sbmt/outbox.rb +4 -0
- 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: 86044914d6babd961a882ecfd9394875e0b67f74a2b92f44db48480bb5096448
|
4
|
+
data.tar.gz: 3ae09e5801c2dcacc9096bae5c2428f2c57445394dd5a3d036c58b1fa63121d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f180114bce2540c91f6c942195fa59c51bcfea67bd984ee5b7db19fd95653933492ce30f7890833e879469b2bb08ca5bcfad2b5a8efa8221eae904b2839a42f
|
7
|
+
data.tar.gz: e9aeadbc87d76a0f86c7b7c9ddad157c45851e3941901bf4ff249c116a7d32827645157ed644709ba59756569af0d9637e0b66c0c9b0c10937ba6b5878ac740d
|
data/README.md
CHANGED
@@ -493,6 +493,7 @@ You can wrap item processing within middlewares. There are three types:
|
|
493
493
|
- server middlewares – triggered inside a daemon; divided into two types:
|
494
494
|
- batch middlewares – executed alongside a batch being fetched from the database
|
495
495
|
- item middlewares – execute alongside an item during processing
|
496
|
+
- polling middlewares - execute with element during pooling
|
496
497
|
|
497
498
|
The order of execution depends on the order specified in the outbox configuration:
|
498
499
|
|
@@ -580,6 +581,25 @@ class MyItemMiddleware
|
|
580
581
|
end
|
581
582
|
```
|
582
583
|
|
584
|
+
Example of an polling middleware:
|
585
|
+
|
586
|
+
```ruby
|
587
|
+
# config/initializers/outbox.rb
|
588
|
+
Rails.application.config.outbox.tap do |config|
|
589
|
+
config.polling_item_middlewares.push(
|
590
|
+
'MyItemMiddleware'
|
591
|
+
)
|
592
|
+
end
|
593
|
+
|
594
|
+
# my_create_polling_middleware.rb
|
595
|
+
class MyPollingItemMiddleware
|
596
|
+
def call(item)
|
597
|
+
# your code
|
598
|
+
yield
|
599
|
+
# your code
|
600
|
+
end
|
601
|
+
end
|
602
|
+
|
583
603
|
## Tracing
|
584
604
|
|
585
605
|
The gem is optionally integrated with OpenTelemetry. If your main application has `opentelemetry-*` gems, the tracing will be configured automatically.
|
data/lib/sbmt/outbox/engine.rb
CHANGED
@@ -64,6 +64,7 @@ module Sbmt
|
|
64
64
|
c.item_process_middlewares = []
|
65
65
|
c.create_item_middlewares = []
|
66
66
|
c.create_batch_middlewares = []
|
67
|
+
c.polling_item_middlewares = []
|
67
68
|
|
68
69
|
if defined?(::Sentry)
|
69
70
|
c.batch_process_middlewares.push("Sbmt::Outbox::Middleware::Sentry::TracingBatchProcessMiddleware")
|
@@ -10,9 +10,9 @@ module Sbmt
|
|
10
10
|
module Outbox
|
11
11
|
module V2
|
12
12
|
class Poller < BoxProcessor
|
13
|
-
delegate :poller_config, :logger, to: "Sbmt::Outbox"
|
13
|
+
delegate :poller_config, :polling_item_middlewares, :logger, to: "Sbmt::Outbox"
|
14
14
|
delegate :box_worker, to: "Yabeda"
|
15
|
-
attr_reader :partitions_count, :lock_timeout, :regular_items_batch_size, :retryable_items_batch_size, :max_buffer_size, :max_batch_size, :throttler
|
15
|
+
attr_reader :partitions_count, :lock_timeout, :regular_items_batch_size, :retryable_items_batch_size, :max_buffer_size, :max_batch_size, :throttler, :middleware_builder
|
16
16
|
|
17
17
|
def initialize(
|
18
18
|
boxes,
|
@@ -35,6 +35,7 @@ module Sbmt
|
|
35
35
|
super(boxes: boxes, threads_count: threads_count || poller_config.threads_count, name: "poller", redis: redis)
|
36
36
|
|
37
37
|
@throttler = PollThrottler.build(throttler_tactic || poller_config.tactic || "default", self.redis, poller_config)
|
38
|
+
@middleware_builder = Middleware::Builder.new(polling_item_middlewares)
|
38
39
|
end
|
39
40
|
|
40
41
|
def throttle(worker_number, poll_task, result)
|
@@ -42,7 +43,7 @@ module Sbmt
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def process_task(_worker_number, task)
|
45
|
-
poll(task)
|
46
|
+
middleware_builder.call(task) { poll(task) }
|
46
47
|
end
|
47
48
|
|
48
49
|
private
|
data/lib/sbmt/outbox/version.rb
CHANGED
data/lib/sbmt/outbox.rb
CHANGED
@@ -170,5 +170,9 @@ module Sbmt
|
|
170
170
|
def create_batch_middlewares
|
171
171
|
@create_batch_middlewares ||= config.create_batch_middlewares.map(&:constantize)
|
172
172
|
end
|
173
|
+
|
174
|
+
def polling_item_middlewares
|
175
|
+
@polling_item_middlewares ||= config.polling_item_middlewares.map(&:constantize)
|
176
|
+
end
|
173
177
|
end
|
174
178
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sbmt-outbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sbermarket Ruby-Platform Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: connection_pool
|