ruby_event_store-outbox 0.0.20 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 151cc4dc1f5abead45b181c09dd52ade1850944b1f240cf222778ab7891ca146
4
- data.tar.gz: 95ff963b0957cd62a9456764f6f87f3e3dac8e4484ebd886c8ac3c5434db3026
3
+ metadata.gz: eca098a782c640bdb2bcfc7023a88b37b1c54025f785cb40c04abcafdd23ec9a
4
+ data.tar.gz: 419c3f82f9f553f1c7dab304633093ff27ff32a10d4a3d60bd26fb9f07064873
5
5
  SHA512:
6
- metadata.gz: a894a74e5a4db50a5f9e3d030ea97ea725bbf0098f79d986d8ab7ead14dcfcf8b8daca4187d87e16a836ca40039bd6d950fa8dc55ca47aa8d3977d2bf69b078e
7
- data.tar.gz: 5a251df0856e1dadae4868871fb3a428fd4b9ccb8f4d17dfcc9d623559c9c4ea5cfb58ec566589ed3358724e6063f9f40a43d62d15b3bde5bc6814bd73ee0758
6
+ metadata.gz: b1f689cd6077646bbb366089fec855e8c9b5b4550b7a44c4ff95d02f57eba05e3b87a06d697195424c58cf6384b0bd6df6f58eddcadf426cf34de62c683fa903
7
+ data.tar.gz: 9c8f0b506b8ffc9b439fa0d642b3ec847021783df36d60c774977d9efcfd97325f49b438c1ba31e4c8f02d8b78175c0948cbf1d011047d7235f1df54ed930d54
@@ -2,17 +2,18 @@ module RubyEventStore
2
2
  module Outbox
3
3
  module CleanupStrategies
4
4
  class CleanOldEnqueued
5
- def initialize(repository, duration)
5
+ def initialize(repository, duration, limit)
6
6
  @repository = repository
7
7
  @duration = duration
8
+ @limit = limit
8
9
  end
9
10
 
10
11
  def call(fetch_specification)
11
- repository.delete_enqueued_older_than(fetch_specification, duration)
12
+ repository.delete_enqueued_older_than(fetch_specification, duration, limit)
12
13
  end
13
14
 
14
15
  private
15
- attr_reader :repository, :duration
16
+ attr_reader :repository, :duration, :limit
16
17
  end
17
18
  end
18
19
  end
@@ -15,6 +15,7 @@ module RubyEventStore
15
15
  batch_size: 100,
16
16
  metrics_url: nil,
17
17
  cleanup_strategy: :none,
18
+ cleanup_limit: :all,
18
19
  sleep_on_empty: 0.5
19
20
  }
20
21
  Options = Struct.new(*DEFAULTS.keys)
@@ -57,6 +58,10 @@ module RubyEventStore
57
58
  options.cleanup_strategy = cleanup_strategy
58
59
  end
59
60
 
61
+ option_parser.on("--cleanup-limit=LIMIT", "Amount of records removed in single cleanup run. One of: all or number of records that should be removed. Default: all") do |cleanup_limit|
62
+ options.cleanup_limit = cleanup_limit
63
+ end
64
+
60
65
  option_parser.on("--sleep-on-empty=SLEEP_TIME", Float, "How long to sleep before next check when there was nothing to do. Default: 0.5") do |sleep_on_empty|
61
66
  options.sleep_on_empty = sleep_on_empty
62
67
  end
@@ -21,6 +21,7 @@ module RubyEventStore
21
21
  database_url:,
22
22
  redis_url:,
23
23
  cleanup:,
24
+ cleanup_limit:,
24
25
  sleep_on_empty:
25
26
  )
26
27
  @split_keys = split_keys
@@ -29,6 +30,7 @@ module RubyEventStore
29
30
  @database_url = database_url
30
31
  @redis_url = redis_url
31
32
  @cleanup = cleanup
33
+ @cleanup_limit = cleanup_limit
32
34
  @sleep_on_empty = sleep_on_empty
33
35
  freeze
34
36
  end
@@ -41,11 +43,12 @@ module RubyEventStore
41
43
  database_url: overriden_options.fetch(:database_url, database_url),
42
44
  redis_url: overriden_options.fetch(:redis_url, redis_url),
43
45
  cleanup: overriden_options.fetch(:cleanup, cleanup),
46
+ cleanup_limit: overriden_options.fetch(:cleanup_limit, cleanup_limit),
44
47
  sleep_on_empty: overriden_options.fetch(:sleep_on_empty, sleep_on_empty)
45
48
  )
46
49
  end
47
50
 
48
- attr_reader :split_keys, :message_format, :batch_size, :database_url, :redis_url, :cleanup, :sleep_on_empty
51
+ attr_reader :split_keys, :message_format, :batch_size, :database_url, :redis_url, :cleanup, :cleanup_limit, :sleep_on_empty
49
52
  end
50
53
 
51
54
  def initialize(consumer_uuid, configuration, clock: Time, logger:, metrics:)
@@ -68,7 +71,7 @@ module RubyEventStore
68
71
  when :none
69
72
  CleanupStrategies::None.new
70
73
  else
71
- CleanupStrategies::CleanOldEnqueued.new(repository, ActiveSupport::Duration.parse(configuration.cleanup))
74
+ CleanupStrategies::CleanOldEnqueued.new(repository, ActiveSupport::Duration.parse(configuration.cleanup), configuration.cleanup_limit)
72
75
  end
73
76
  end
74
77
 
@@ -142,11 +142,12 @@ module RubyEventStore
142
142
  record.update_column(:enqueued_at, now)
143
143
  end
144
144
 
145
- def delete_enqueued_older_than(fetch_specification, duration)
146
- Record
145
+ def delete_enqueued_older_than(fetch_specification, duration, limit)
146
+ scope = Record
147
147
  .for_fetch_specification(fetch_specification)
148
148
  .where("enqueued_at < ?", duration.ago)
149
- .delete_all
149
+ scope = scope.limit(limit) unless limit == :all
150
+ scope.delete_all
150
151
  :ok
151
152
  rescue ActiveRecord::Deadlocked
152
153
  :deadlocked
@@ -10,11 +10,11 @@ module RubyEventStore
10
10
  def call(klass, args)
11
11
  sidekiq_client = Sidekiq::Client.new(Sidekiq.redis_pool)
12
12
  item = {
13
+ 'args' => args.map(&:to_h).map {|h| h.transform_keys(&:to_s)},
13
14
  'class' => klass,
14
- 'args' => args.map(&:to_h),
15
15
  }
16
16
  normalized_item = sidekiq_client.__send__(:normalize_item, item)
17
- payload = sidekiq_client.__send__(:process_single, normalized_item.fetch('class'), normalized_item)
17
+ payload = sidekiq_client.middleware.invoke(normalized_item['class'], normalized_item, normalized_item['queue'], Sidekiq.redis_pool) { normalized_item }
18
18
  if payload
19
19
  Repository::Record.create!(
20
20
  format: SIDEKIQ5_FORMAT,
@@ -5,7 +5,7 @@ require_relative "sidekiq_producer"
5
5
  module RubyEventStore
6
6
  module Outbox
7
7
  class SidekiqScheduler
8
- def initialize(serializer: YAML)
8
+ def initialize(serializer: RubyEventStore::Serializers::YAML)
9
9
  @serializer = serializer
10
10
  @sidekiq_producer = SidekiqProducer.new
11
11
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RubyEventStore
4
4
  module Outbox
5
- VERSION = "0.0.20"
5
+ VERSION = "0.0.23"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_event_store-outbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arkency
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-01 00:00:00.000000000 Z
11
+ date: 2022-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby_event_store
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '5.2'
41
- description:
41
+ description:
42
42
  email: dev@arkency.com
43
43
  executables:
44
44
  - res_outbox
@@ -75,7 +75,7 @@ metadata:
75
75
  source_code_uri: https://github.com/RailsEventStore/rails_event_store
76
76
  bug_tracker_uri: https://github.com/RailsEventStore/rails_event_store/issues
77
77
  rubygems_mfa_required: 'true'
78
- post_install_message:
78
+ post_install_message:
79
79
  rdoc_options: []
80
80
  require_paths:
81
81
  - lib
@@ -90,8 +90,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0'
92
92
  requirements: []
93
- rubygems_version: 3.2.22
94
- signing_key:
93
+ rubygems_version: 3.3.9
94
+ signing_key:
95
95
  specification_version: 4
96
96
  summary: Active Record based outbox for Ruby Event Store
97
97
  test_files: []