sbmt-outbox 6.5.0 → 6.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e88f22ff7adf6d76e9fb116d0de7d825986114fc4e68a289e286c5e3d9d24fde
4
- data.tar.gz: f3ec1429fba3c58bc741ab2c6ebbe9cc1483716cc703a76385c90c09f1e70e24
3
+ metadata.gz: a86388ca6b13cdaef9411bd8baf1ea045fcc1b941721cdb8d4fb15bda4db29be
4
+ data.tar.gz: 6fbc5a6e5d62df9aaf1cf2f0afdc3cf49e8bf5ccdc0a49d86a0b8feb8e51f200
5
5
  SHA512:
6
- metadata.gz: a4afedde029080834e7d379402c7832b5d6dfaa6c1d86c25b38358bc95fb9b7db2d1ade8458a2b28750f2a6a8247bede8838198a7b15cb1397b944f6a0e4b174
7
- data.tar.gz: 7524112c3ec1e28a594af7fd44bd7cb18bd0e52dc199fa6c327314245e3ca41160aaf28922d94cdedb59c56f7faf528871a216f0d02dae11023c599f62bb2acf
6
+ metadata.gz: bca4330c17aa8d6d8f6563ebc52dae02d9029fb01580b9294ffd5d20822768f95f5c41a0c5bdd733d9f6481632f44a754ce67079cf843e9cf3c58ada9f9fbb39
7
+ data.tar.gz: 3c24bf5fa9af05b1ef48f38ff20519466c5f63a47a1acbb5bf788d7e197c8af17759581c52443b8650c8ff4f3680bbd48aee3a8b224623e6097176aa284c5a11
data/README.md CHANGED
@@ -122,7 +122,7 @@ Rails.application.config.outbox.tap do |config|
122
122
  config.paths << Rails.root.join("config/outbox.yml").to_s # optional; configuration file paths, deep merged at the application start, useful with Rails engines
123
123
 
124
124
  # optional (worker v2: default)
125
- c.poller = ActiveSupport::OrderedOptions.new.tap do |pc|
125
+ config.poller = ActiveSupport::OrderedOptions.new.tap do |pc|
126
126
  # max parallel threads (per box-item, globally)
127
127
  pc.concurrency = 6
128
128
  # max threads count (per worker process)
@@ -152,7 +152,7 @@ Rails.application.config.outbox.tap do |config|
152
152
  end
153
153
 
154
154
  # optional (worker v2: default)
155
- c.processor = ActiveSupport::OrderedOptions.new.tap do |pc|
155
+ config.processor = ActiveSupport::OrderedOptions.new.tap do |pc|
156
156
  # max threads count (per worker process)
157
157
  pc.threads_count = 4
158
158
  # maximum processing time of the batch, after which the batch will be considered hung and processing will be aborted
@@ -236,6 +236,7 @@ default: &default
236
236
  owner: my_outbox_item_team # optional, used in Yabeda metrics
237
237
  retention: P1W # retention period, https://en.wikipedia.org/wiki/ISO_8601#Durations
238
238
  max_retries: 3 # default 0, the number of retries before the item will be marked as failed
239
+ strict_order: false # optional, default
239
240
  transports: # transports section
240
241
  produce_message: # underscored transport class name
241
242
  # transport reserved options
@@ -255,6 +256,10 @@ production:
255
256
  <<: *default
256
257
  bucket_size: 256
257
258
  ```
259
+ __CAUTION__:
260
+ - ⚠️ If this option is enabled and an error occurs while processing a message in a bucket,
261
+ subsequent messages in that bucket won't be processed until the current message is either skipped or successfully processed
262
+ - ⚠️ Cannot use `retry_strategies` and the `strict_order` option at the same time
258
263
 
259
264
  ```ruby
260
265
  # app/services/import_order.rb
@@ -6,7 +6,7 @@ module Sbmt
6
6
  self.abstract_class = true
7
7
 
8
8
  class << self
9
- delegate :owner, to: :config
9
+ delegate :owner, :strict_order, to: :config
10
10
 
11
11
  def box_type
12
12
  raise NotImplementedError
@@ -134,6 +134,7 @@ module Sbmt
134
134
  end
135
135
 
136
136
  def max_retries_exceeded?
137
+ return false if config.strict_order
137
138
  return true unless retriable?
138
139
 
139
140
  errors_count > config.max_retries
@@ -16,7 +16,7 @@ module Sbmt
16
16
  end
17
17
 
18
18
  def owner
19
- return @owner if defined? @owner
19
+ return @owner if defined?(@owner)
20
20
 
21
21
  @owner = options[:owner].presence || yaml_config[:owner].presence
22
22
  end
@@ -57,7 +57,14 @@ module Sbmt
57
57
  return @retry_strategies if defined?(@retry_strategies)
58
58
 
59
59
  configured_strategies = options[:retry_strategies]
60
- strategies = configured_strategies.presence || %w[exponential_backoff latest_available]
60
+
61
+ raise ConfigError, "You cannot use retry_strategies and the strict_order option at the same time." if strict_order.present? && configured_strategies.present?
62
+
63
+ strategies = if strict_order.present? && configured_strategies.nil?
64
+ []
65
+ else
66
+ configured_strategies.presence || %w[exponential_backoff latest_available]
67
+ end
61
68
 
62
69
  @retry_strategies ||= Array.wrap(strategies).map do |str_name|
63
70
  "Sbmt::Outbox::RetryStrategies::#{str_name.camelize}".constantize
@@ -108,6 +115,12 @@ module Sbmt
108
115
  end
109
116
  end
110
117
 
118
+ def strict_order
119
+ return @strict_order if defined?(@strict_order)
120
+
121
+ @strict_order = options[:strict_order].presence
122
+ end
123
+
111
124
  private
112
125
 
113
126
  attr_accessor :box_id, :box_name
@@ -68,15 +68,18 @@ module Sbmt
68
68
  def process(task)
69
69
  lock_timer = Cutoff.new(lock_timeout)
70
70
  last_id = 0
71
+ strict_order = task.item_class.config.strict_order
71
72
 
72
73
  box_worker.item_execution_runtime.measure(task.yabeda_labels) do
73
74
  Outbox.database_switcher.use_master do
74
75
  task.ids.each do |id|
75
- ProcessItem.call(task.item_class, id, worker_version: task.yabeda_labels[:worker_version])
76
+ result = ProcessItem.call(task.item_class, id, worker_version: task.yabeda_labels[:worker_version])
76
77
 
77
78
  box_worker.job_items_counter.increment(task.yabeda_labels)
78
79
  last_id = id
79
80
  lock_timer.checkpoint!
81
+
82
+ break if strict_order == true && result.failure?
80
83
  end
81
84
  end
82
85
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sbmt
4
4
  module Outbox
5
- VERSION = "6.5.0"
5
+ VERSION = "6.6.0"
6
6
  end
7
7
  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.5.0
4
+ version: 6.6.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: 2024-06-05 00:00:00.000000000 Z
11
+ date: 2024-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool
@@ -636,7 +636,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
636
636
  - !ruby/object:Gem::Version
637
637
  version: '0'
638
638
  requirements: []
639
- rubygems_version: 3.5.11
639
+ rubygems_version: 3.1.6
640
640
  signing_key:
641
641
  specification_version: 4
642
642
  summary: Outbox service