ruby_event_store-outbox 0.0.21 → 0.0.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby_event_store/outbox/cleanup_strategies/clean_old_enqueued.rb +4 -3
- data/lib/ruby_event_store/outbox/cli.rb +6 -0
- data/lib/ruby_event_store/outbox/consumer.rb +5 -2
- data/lib/ruby_event_store/outbox/repository.rb +4 -3
- data/lib/ruby_event_store/outbox/sidekiq_producer.rb +2 -2
- data/lib/ruby_event_store/outbox/sidekiq_scheduler.rb +1 -1
- data/lib/ruby_event_store/outbox/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c7c7068c9bd49735031384ece752500cc641f5035bc1f7953104e64a3d22dd8
|
4
|
+
data.tar.gz: 2975fdb8c2dfe6fc9843ce5efd00042a2c16d2d9ec2e6524598507a4fcb36dc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a1118657e1c164df15f9eb7d117adb80a4f7a693eed4a3974dc4a9b0f3bdbd15504f441fe50dbd0fdf5318fae6205dd2c4cadeebd0c4897a61fb4be4ea2e382
|
7
|
+
data.tar.gz: 7a84d03ea98a5d2b0019f2eedf3c76b509f5bb25c44fb2db7dc9a952c1752cf4db17ee284fd9ee8bce4295267743a29222d26bee1709d554375f95c64ebb1203
|
@@ -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
|
@@ -87,6 +92,7 @@ module RubyEventStore
|
|
87
92
|
database_url: options.database_url,
|
88
93
|
redis_url: options.redis_url,
|
89
94
|
cleanup: options.cleanup_strategy,
|
95
|
+
cleanup_limit: options.cleanup_limit,
|
90
96
|
sleep_on_empty: options.sleep_on_empty,
|
91
97
|
)
|
92
98
|
metrics = Metrics.from_url(options.metrics_url)
|
@@ -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
|
-
|
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
|
-
'class' => klass,
|
14
13
|
'args' => args.map(&:to_h).map {|h| h.transform_keys(&:to_s)},
|
14
|
+
'class' => klass,
|
15
15
|
}
|
16
16
|
normalized_item = sidekiq_client.__send__(:normalize_item, item)
|
17
|
-
payload = sidekiq_client.
|
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
|
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.
|
4
|
+
version: 0.0.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arkency
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
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
|
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
requirements: []
|
93
|
-
rubygems_version: 3.
|
93
|
+
rubygems_version: 3.3.9
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: Active Record based outbox for Ruby Event Store
|