rails-transactional-outbox 0.3.1 → 0.4.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: 3e55a23c67288d7804bffc02cf8bfa1f36fc93562600f2002cce9393ca097b95
4
- data.tar.gz: 64693c24b6affcf0357973f439aa0907636537c74ffd247b93ddf77984c0f6fa
3
+ metadata.gz: 20d98c7e305f01ecd8e54b92170a117c01a412d050acab60899835b99a0d7d0c
4
+ data.tar.gz: 1658aadc54b3a01dd1e48274055befa210638df3b1fdc60bdd5a0bb2f858e1ae
5
5
  SHA512:
6
- metadata.gz: 2ce32e65ec889efa9e3c56931c9a8146ffeff13178ab67aaf242b4dad72d22d33c9949bfde0d8609bbd610a1309d9fb26b5eef73be949b14ec9803444f181810
7
- data.tar.gz: 1484e44ad3673815550375b95e78dfc08f235535dd47f519c7a26bf2ed38e781b16d9ff9e1acd69b8dfa029967e55f1308302d1989c36a03b97b37cb9fd077fd
6
+ metadata.gz: 75c6ef520d685476d27fc71f3c3bcac986248ab5d62addd2840238ed020136622cea9c4d20f0ade4fe6d693ffa3545531152d4a57465b72a6cb7a91112a2d5d0
7
+ data.tar.gz: 9efa9ef99b4c610f89c9ae22d2b5bd0592c0535667d46636e69a8d219cb3e92dda648d315ccf56ca8cfe01f3ae9ccb8588d4f51742072a6309829a68da33614e
data/.rubocop.yml CHANGED
@@ -151,3 +151,6 @@ RSpec/AnyInstance:
151
151
  RSpec/VerifiedDoubles:
152
152
  Exclude:
153
153
  - 'spec/rails_transactional_outbox/runner_spec.rb'
154
+
155
+ Layout/LineLength:
156
+ Max: 125
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.0] - 2024-01-25
4
+
5
+ - add config option to specify causality keys limit
6
+
3
7
  ## [0.3.1] - 2023-05-24
4
8
 
5
9
  - add config option whether to raise error when outbox entry record is not found
data/Gemfile.lock CHANGED
@@ -9,7 +9,7 @@ GIT
9
9
  PATH
10
10
  remote: .
11
11
  specs:
12
- rails-transactional-outbox (0.3.1)
12
+ rails-transactional-outbox (0.4.0)
13
13
  activerecord (>= 5)
14
14
  activesupport (>= 3.2)
15
15
  concurrent-ruby
@@ -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.8)
124
+ zeitwerk (2.6.12)
125
125
 
126
126
  PLATFORMS
127
127
  x86_64-darwin-18
data/README.md CHANGED
@@ -45,6 +45,7 @@ Rails.application.config.to_prepare do
45
45
  config.lock_expiry_time = 10_000 # not required, defaults to 10_000, the unit is milliseconds
46
46
  config.outbox_entries_processor = `RailsTransactionalOutbox::OutboxEntriesProcessors::OrderedByCausalityKeyProcessor`.new # not required, defaults to RailsTransactionalOutbox::OutboxEntriesProcessors::NonOrderedProcessor.new
47
47
  config.outbox_entry_causality_key_resolver = ->(model) { model.tenant_id } # not required, defaults to a lambda returning nil. Needed when using `outbox_entry_causality_key_resolver`
48
+ config.unprocessed_causality_keys_limit = 100_000 # not required, defaults to 10_000. Might be a good idea to decrease the value when you start experiencing OOMs - they are likely to be caused by fetching too many causality keys. It is likely to happen when you have huge amount of records to process.
48
49
  end
49
50
  end
50
51
  ```
@@ -6,7 +6,7 @@ class RailsTransactionalOutbox
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
8
  :lock_client, :lock_expiry_time, :outbox_entry_causality_key_resolver,
9
- :raise_not_found_model_error
9
+ :raise_not_found_model_error, :unprocessed_causality_keys_limit
10
10
 
11
11
  def error_handler
12
12
  @error_handler || RailsTransactionalOutbox::ErrorHandlers::NullErrorHandler
@@ -55,5 +55,11 @@ class RailsTransactionalOutbox
55
55
  def outbox_entry_causality_key_resolver
56
56
  @outbox_entry_causality_key_resolver || ->(_model) {}
57
57
  end
58
+
59
+ def unprocessed_causality_keys_limit
60
+ return @unprocessed_causality_keys_limit.to_i if defined?(@unprocessed_causality_keys_limit)
61
+
62
+ 10_000
63
+ end
58
64
  end
59
65
  end
@@ -24,9 +24,10 @@ class RailsTransactionalOutbox
24
24
  .where("retry_at IS NULL OR retry_at <= ?", Time.current)
25
25
  }
26
26
 
27
- def self.unprocessed_causality_keys
27
+ def self.unprocessed_causality_keys(limit: RailsTransactionalOutbox.configuration.unprocessed_causality_keys_limit)
28
28
  processable_now
29
29
  .select("causality_key")
30
+ .limit(limit)
30
31
  .distinct
31
32
  .pluck(:causality_key)
32
33
  end
@@ -17,9 +17,7 @@ class RailsTransactionalOutbox
17
17
  def call(record)
18
18
  model = record.infer_model
19
19
  if model.nil?
20
- if RailsTransactionalOutbox.configuration.raise_not_found_model_error?
21
- raise CouldNotFindModelError.new(record)
22
- end
20
+ raise CouldNotFindModelError.new(record) if RailsTransactionalOutbox.configuration.raise_not_found_model_error?
23
21
 
24
22
  return
25
23
  end
@@ -3,5 +3,5 @@
3
3
  class RailsTransactionalOutbox
4
4
  module Version
5
5
  end
6
- VERSION = "0.3.1"
6
+ VERSION = "0.4.0"
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.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karol Galanciak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-26 00:00:00.000000000 Z
11
+ date: 2024-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord