ruby_event_store-outbox 0.0.22 → 0.0.23
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 +5 -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/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eca098a782c640bdb2bcfc7023a88b37b1c54025f785cb40c04abcafdd23ec9a
|
4
|
+
data.tar.gz: 419c3f82f9f553f1c7dab304633093ff27ff32a10d4a3d60bd26fb9f07064873
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
149
|
+
scope = scope.limit(limit) unless limit == :all
|
150
|
+
scope.delete_all
|
150
151
|
:ok
|
151
152
|
rescue ActiveRecord::Deadlocked
|
152
153
|
:deadlocked
|
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.23
|
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
|