rails-transactional-outbox 0.3.0 → 0.3.1

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: 7981d03fa1319ccf83fe5f66ac64869ef024e8add13de49f6af43b26ff39ac3e
4
- data.tar.gz: e2f5048f5c4f5700b95b247064cc4e2fe9d8601b6df63d39b1e06896aeb1e915
3
+ metadata.gz: 3e55a23c67288d7804bffc02cf8bfa1f36fc93562600f2002cce9393ca097b95
4
+ data.tar.gz: 64693c24b6affcf0357973f439aa0907636537c74ffd247b93ddf77984c0f6fa
5
5
  SHA512:
6
- metadata.gz: e903bcb6ee6c1b58d77b7c9b0dff41297e44b81c45457df0888caf6ecbdf2fa0f7254f9424cac14db2d31933e6f9790438cf2a9e232cb6af06405f9985221ceb
7
- data.tar.gz: 8296fbab0324e8b0fa6410187e0fb59392121aecfccab2301fecff8fc1b51d815eaa71af78fdbd1d7c67f11573fc06d9598ec9e719d01738fc72d92646a33e0a
6
+ metadata.gz: 2ce32e65ec889efa9e3c56931c9a8146ffeff13178ab67aaf242b4dad72d22d33c9949bfde0d8609bbd610a1309d9fb26b5eef73be949b14ec9803444f181810
7
+ data.tar.gz: 1484e44ad3673815550375b95e78dfc08f235535dd47f519c7a26bf2ed38e781b16d9ff9e1acd69b8dfa029967e55f1308302d1989c36a03b97b37cb9fd077fd
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.1] - 2023-05-24
4
+
5
+ - add config option whether to raise error when outbox entry record is not found
6
+
3
7
  ## [0.3.0] - 2022-12-20
4
8
 
5
9
  - Move to file-based healthchecks, instead of using Redis-based ones.
data/Gemfile.lock CHANGED
@@ -9,7 +9,7 @@ GIT
9
9
  PATH
10
10
  remote: .
11
11
  specs:
12
- rails-transactional-outbox (0.3.0)
12
+ rails-transactional-outbox (0.3.1)
13
13
  activerecord (>= 5)
14
14
  activesupport (>= 3.2)
15
15
  concurrent-ruby
@@ -55,7 +55,7 @@ GEM
55
55
  dry-events (~> 1.0, < 2)
56
56
  exponential-backoff (0.0.4)
57
57
  ffi (1.15.5)
58
- file-based-healthcheck (0.1.1)
58
+ file-based-healthcheck (0.2.0)
59
59
  activesupport (>= 3.2)
60
60
  i18n (1.12.0)
61
61
  concurrent-ruby (~> 1.0)
@@ -121,7 +121,7 @@ GEM
121
121
  tzinfo (2.0.5)
122
122
  concurrent-ruby (~> 1.0)
123
123
  unicode-display_width (2.2.0)
124
- zeitwerk (2.6.6)
124
+ zeitwerk (2.6.8)
125
125
 
126
126
  PLATFORMS
127
127
  x86_64-darwin-18
data/README.md CHANGED
@@ -39,6 +39,7 @@ Rails.application.config.to_prepare do
39
39
  config.transactional_outbox_worker_idle_delay_multiplier = 5 # optional, defaults to 1, if there are no outbox entries to be processed, then the sleep time for the thread will be equal to transactional_outbox_worker_idle_delay_multiplier * transactional_outbox_worker_sleep_seconds
40
40
  config.outbox_batch_size = 100 # optional, defaults to 100
41
41
  config.add_record_processor(MyCustomOperationProcerssor) # optional, by default it contains only one processor for ActiveRecord, but you could add more
42
+ config.raise_not_found_model_error = true # optional, defaults to true. Should the error be raised if outbox entry model is not found
42
43
 
43
44
  config.lock_client = Redlock::Client.new([ENV["REDIS_URL"]]) # required if you want to use RailsTransactionalOutbox::OutboxEntriesProcessors::OrderedByCausalityKeyProcessor, defaults to RailsTransactionalOutbox::NullLockClient. Check its interface and the interface of `redlock` gem. To cut the long story short, when the lock is acquired, a hash with the structure outlined in RailsTransactionalOutbox::NullLockClient should be yielded, if the lock is not acquired, a nil should be yielded.
44
45
  config.lock_expiry_time = 10_000 # not required, defaults to 10_000, the unit is milliseconds
@@ -5,7 +5,8 @@ class RailsTransactionalOutbox
5
5
  attr_accessor :database_connection_provider, :logger, :outbox_model, :transaction_provider
6
6
  attr_writer :error_handler, :transactional_outbox_worker_sleep_seconds,
7
7
  :transactional_outbox_worker_idle_delay_multiplier, :outbox_batch_size, :outbox_entries_processor,
8
- :lock_client, :lock_expiry_time, :outbox_entry_causality_key_resolver
8
+ :lock_client, :lock_expiry_time, :outbox_entry_causality_key_resolver,
9
+ :raise_not_found_model_error
9
10
 
10
11
  def error_handler
11
12
  @error_handler || RailsTransactionalOutbox::ErrorHandlers::NullErrorHandler
@@ -35,6 +36,14 @@ class RailsTransactionalOutbox
35
36
  @outbox_entries_processor ||= RailsTransactionalOutbox::OutboxEntriesProcessors::NonOrderedProcessor.new
36
37
  end
37
38
 
39
+ def raise_not_found_model_error
40
+ return @raise_not_found_model_error if defined?(@raise_not_found_model_error)
41
+
42
+ true
43
+ end
44
+
45
+ alias_method :raise_not_found_model_error?, :raise_not_found_model_error
46
+
38
47
  def lock_client
39
48
  @lock_client || RailsTransactionalOutbox::NullLockClient
40
49
  end
@@ -15,7 +15,14 @@ class RailsTransactionalOutbox
15
15
  end
16
16
 
17
17
  def call(record)
18
- model = record.infer_model or raise CouldNotFindModelError.new(record)
18
+ model = record.infer_model
19
+ if model.nil?
20
+ if RailsTransactionalOutbox.configuration.raise_not_found_model_error?
21
+ raise CouldNotFindModelError.new(record)
22
+ end
23
+
24
+ return
25
+ end
19
26
  model.previous_changes = record.transformed_changeset.with_indifferent_access
20
27
  model.reliable_after_commit_callbacks.for_event_type(record.event_type).each do |callback|
21
28
  callback.call(model)
@@ -3,5 +3,5 @@
3
3
  class RailsTransactionalOutbox
4
4
  module Version
5
5
  end
6
- VERSION = "0.3.0"
6
+ VERSION = "0.3.1"
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-transactional-outbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karol Galanciak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-20 00:00:00.000000000 Z
11
+ date: 2023-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord