sbmt-outbox 6.8.0 → 6.10.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: 7eeda1fb96153d344c166cc65ba9dd8cfcfdfb1402184258e37efff70ec8d2ec
4
- data.tar.gz: feb94667bbb5777cfc467db6d987f7337fa8da5b7badd09ce59a88a964f71f26
3
+ metadata.gz: e9c1d6731755da78bfaf755eb229d0b0574cb305aa09be61ff4b582297be40ca
4
+ data.tar.gz: 33e1cc5bf44df4ab4fa85ed41552c86a5990bc4570c3019408800359823cc432
5
5
  SHA512:
6
- metadata.gz: 1f095fb1ba849215724ad17e6f1ad27af8cc67674756022f2d4764109ce2231a8b71696b75f8bbb9562bc6754de4daeffae8a5d817588c918f9283d745ce01e8
7
- data.tar.gz: ad06ba71f618763fca9712d33c298466b586fe84db6f9fe941a3582612a4de930e1e2892cc0a7a3197ff8d6f93bbf0018aa76e0caf47051568debba2f6dc1b7b
6
+ metadata.gz: '09554fa859af8e022eb5b48ed2595ee34fa946bd4d43bf22b83435f5fbffd57eba30cde7324eebd8e282132ec98d10379e939d2e257727f309fec77a67f3b041'
7
+ data.tar.gz: ed32aa05783c3a83ee92ae9a30e6d059d608ecfe0451c95a8b6ab7e72bda4a6deb6684489cc69ca83b28322e1fb58cce9438868909db18fc2f33424c68e4e748
data/README.md CHANGED
@@ -235,7 +235,7 @@ create_table :my_outbox_items do |t|
235
235
  end
236
236
 
237
237
  add_index :my_outbox_items, :uuid, unique: true
238
- add_index :my_outbox_items, [:status, :bucket, :errors_count]
238
+ add_index :my_outbox_items, [:status, :id, :bucket], algorithm: :concurrently, include: [:errors_count]
239
239
  add_index :my_outbox_items, [:event_name, :event_key, :id]
240
240
  add_index :my_outbox_items, :created_at
241
241
  ```
@@ -11,7 +11,7 @@ module Sbmt
11
11
 
12
12
  METRICS_COUNTERS = %i[error_counter retry_counter sent_counter fetch_error_counter discarded_counter].freeze
13
13
 
14
- delegate :log_success, :log_failure, to: "Sbmt::Outbox.logger"
14
+ delegate :log_success, :log_info, :log_failure, to: "Sbmt::Outbox.logger"
15
15
  delegate :item_process_middlewares, to: "Sbmt::Outbox"
16
16
  delegate :box_type, :box_name, :owner, to: :item_class
17
17
 
@@ -73,7 +73,7 @@ module Sbmt
73
73
  end
74
74
 
75
75
  unless item.for_processing?
76
- log_error("already processed")
76
+ log_info("already processed")
77
77
  counters[:fetch_error_counter] += 1
78
78
  return Failure(:already_processed)
79
79
  end
@@ -154,7 +154,7 @@ module Sbmt
154
154
  # rubocop:enable Metrics/MethodLength
155
155
 
156
156
  def track_failed(ex_or_msg, item = nil)
157
- log_error(ex_or_msg, item)
157
+ log_processing_error(ex_or_msg, item)
158
158
 
159
159
  item&.touch_processed_at
160
160
  item&.add_error(ex_or_msg)
@@ -170,6 +170,8 @@ module Sbmt
170
170
  counters[:retry_counter] += 1
171
171
  item.pending!
172
172
  end
173
+ rescue => e
174
+ log_error_handling_error(e, item)
173
175
  end
174
176
 
175
177
  def track_successed(item)
@@ -196,18 +198,28 @@ module Sbmt
196
198
  counters[:discarded_counter] += 1
197
199
  end
198
200
 
199
- def log_error(ex_or_msg, item = nil)
201
+ def log_processing_error(ex_or_msg, item = nil)
200
202
  text = format_exception_error(ex_or_msg)
201
203
 
202
204
  msg = "Failed processing #{box_type} item with error: #{text}.\n" \
203
205
  "Record: #{item_class.name}##{item_id}.\n" \
204
206
  "#{item&.log_details&.to_json}"
205
207
 
206
- log_failure(msg, backtrace: format_backtrace(ex_or_msg))
208
+ log_failure(msg, stacktrace: format_backtrace(ex_or_msg))
207
209
  end
208
210
 
209
- def format_exception_error(e)
210
- text = if e.respond_to?(:cause) && !e.cause.nil?
211
+ def log_error_handling_error(handling_error, item = nil)
212
+ text = format_exception_error(handling_error, extract_cause: false)
213
+
214
+ msg = "Could not persist status of failed #{box_type} item due to error: #{text}.\n" \
215
+ "Record: #{item_class.name}##{item_id}.\n" \
216
+ "#{item&.log_details&.to_json}"
217
+
218
+ log_failure(msg, stacktrace: format_backtrace(handling_error))
219
+ end
220
+
221
+ def format_exception_error(e, extract_cause: true)
222
+ text = if extract_cause && e.respond_to?(:cause) && !e.cause.nil?
211
223
  "#{format_exception_error(e.cause)}. "
212
224
  else
213
225
  ""
@@ -44,7 +44,7 @@ module Outbox
44
44
  end
45
45
 
46
46
  add_index :#{table_name}, :uuid, unique: true
47
- add_index :#{table_name}, [:status, :bucket, :errors_count]
47
+ add_index :#{table_name}, [:status, :id, :bucket], algorithm: :concurrently, include: [:errors_count]
48
48
  add_index :#{table_name}, [:event_key, :id]
49
49
  add_index :#{table_name}, :created_at
50
50
  RUBY
@@ -218,7 +218,7 @@ module Sbmt
218
218
 
219
219
  logger.log_error(
220
220
  "Failed processing #{job.resource_key} with error: #{e.class} #{e.message}",
221
- backtrace: backtrace
221
+ stacktrace: backtrace
222
222
  )
223
223
  end
224
224
 
@@ -134,7 +134,7 @@ module Sbmt
134
134
 
135
135
  logger.log_error(
136
136
  "Failed processing #{task} with error: #{e.class} #{e.message}",
137
- backtrace: backtrace
137
+ stacktrace: backtrace
138
138
  )
139
139
  end
140
140
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sbmt
4
4
  module Outbox
5
- VERSION = "6.8.0"
5
+ VERSION = "6.10.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.8.0
4
+ version: 6.10.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-09-09 00:00:00.000000000 Z
11
+ date: 2024-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool
@@ -640,7 +640,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
640
640
  - !ruby/object:Gem::Version
641
641
  version: '0'
642
642
  requirements: []
643
- rubygems_version: 3.5.18
643
+ rubygems_version: 3.5.19
644
644
  signing_key:
645
645
  specification_version: 4
646
646
  summary: Outbox service