ruby_event_store-outbox 0.0.18 → 0.0.21
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/consumer.rb +4 -10
- data/lib/ruby_event_store/outbox/legacy_sidekiq_scheduler.rb +24 -0
- data/lib/ruby_event_store/outbox/metrics/test.rb +24 -0
- data/lib/ruby_event_store/outbox/repository.rb +3 -3
- data/lib/ruby_event_store/outbox/sidekiq_producer.rb +2 -1
- data/lib/ruby_event_store/outbox/sidekiq_scheduler.rb +5 -4
- data/lib/ruby_event_store/outbox/version.rb +1 -1
- data/lib/ruby_event_store/outbox.rb +1 -1
- metadata +6 -5
- data/lib/ruby_event_store/outbox/consumer_process.rb +0 -6
- data/lib/ruby_event_store/outbox/sidekiq_message_handler.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5db68b30315551cd7f8e2800c825b12710fd836e20a273b9a8be269955628fa3
|
4
|
+
data.tar.gz: f48d917e788f17731a1338129e399e6fa9919c38683ffed9202ca59b99816540
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0df42b4e20532df318b443950b6741df4130424b988602d6f2a141ff485f101ce845c97471faeb0d9403dc48d0411637f8d41a56a7cfa01ba87c9b2f4a05f9d
|
7
|
+
data.tar.gz: c8acb6b872bc7362d5362ab8299ccb1a4d099b92bf7f2c5685494fb0c7e5c1783d7925eb2c1e9df2f26e30c2e24010a1d59737a3a06d82175775f5278d69ac49
|
@@ -164,24 +164,23 @@ module RubyEventStore
|
|
164
164
|
when :deadlocked
|
165
165
|
logger.warn "Obtaining lock for split_key '#{fetch_specification.split_key}' failed (deadlock)"
|
166
166
|
metrics.write_operation_result("obtain", "deadlocked")
|
167
|
-
|
167
|
+
false
|
168
168
|
when :lock_timeout
|
169
169
|
logger.warn "Obtaining lock for split_key '#{fetch_specification.split_key}' failed (lock timeout)"
|
170
170
|
metrics.write_operation_result("obtain", "lock_timeout")
|
171
|
-
|
171
|
+
false
|
172
172
|
when :taken
|
173
173
|
logger.debug "Obtaining lock for split_key '#{fetch_specification.split_key}' unsuccessful (taken)"
|
174
174
|
metrics.write_operation_result("obtain", "taken")
|
175
|
-
|
175
|
+
false
|
176
176
|
else
|
177
|
-
|
177
|
+
result
|
178
178
|
end
|
179
179
|
end
|
180
180
|
|
181
181
|
def release_lock_for_process(fetch_specification)
|
182
182
|
result = repository.release_lock_for_process(fetch_specification, consumer_uuid)
|
183
183
|
case result
|
184
|
-
when :ok
|
185
184
|
when :deadlocked
|
186
185
|
logger.warn "Releasing lock for split_key '#{fetch_specification.split_key}' failed (deadlock)"
|
187
186
|
metrics.write_operation_result("release", "deadlocked")
|
@@ -191,8 +190,6 @@ module RubyEventStore
|
|
191
190
|
when :not_taken_by_this_process
|
192
191
|
logger.debug "Releasing lock for split_key '#{fetch_specification.split_key}' failed (not taken by this process)"
|
193
192
|
metrics.write_operation_result("release", "not_taken_by_this_process")
|
194
|
-
else
|
195
|
-
raise "Unexpected result #{result}"
|
196
193
|
end
|
197
194
|
end
|
198
195
|
|
@@ -221,15 +218,12 @@ module RubyEventStore
|
|
221
218
|
def cleanup(fetch_specification)
|
222
219
|
result = cleanup_strategy.call(fetch_specification)
|
223
220
|
case result
|
224
|
-
when :ok
|
225
221
|
when :deadlocked
|
226
222
|
logger.warn "Cleanup for split_key '#{fetch_specification.split_key}' failed (deadlock)"
|
227
223
|
metrics.write_operation_result("cleanup", "deadlocked")
|
228
224
|
when :lock_timeout
|
229
225
|
logger.warn "Cleanup for split_key '#{fetch_specification.split_key}' failed (lock timeout)"
|
230
226
|
metrics.write_operation_result("cleanup", "lock_timeout")
|
231
|
-
else
|
232
|
-
raise "Unexpected result #{result}"
|
233
227
|
end
|
234
228
|
end
|
235
229
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "sidekiq_producer"
|
4
|
+
|
5
|
+
module RubyEventStore
|
6
|
+
module Outbox
|
7
|
+
class LegacySidekiqScheduler
|
8
|
+
def initialize
|
9
|
+
@sidekiq_producer = SidekiqProducer.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(klass, serialized_record)
|
13
|
+
sidekiq_producer.call(klass, [serialized_record])
|
14
|
+
end
|
15
|
+
|
16
|
+
def verify(subscriber)
|
17
|
+
Class === subscriber && subscriber.respond_to?(:through_outbox?) && subscriber.through_outbox?
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
attr_reader :sidekiq_producer
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'influxdb'
|
2
|
+
|
3
|
+
module RubyEventStore
|
4
|
+
module Outbox
|
5
|
+
module Metrics
|
6
|
+
class Test
|
7
|
+
def initialize
|
8
|
+
@operation_results = []
|
9
|
+
@queue_stats = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def write_operation_result(operation, result)
|
13
|
+
@operation_results << { operation: operation, result: result }
|
14
|
+
end
|
15
|
+
|
16
|
+
def write_point_queue(enqueued: 0, failed: 0, remaining: 0, format: nil, split_key: nil)
|
17
|
+
@queue_stats << { enqueued: enqueued, failed: failed, remaining: remaining, format: format, split_key: split_key}
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_reader :operation_results, :queue_stats
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -36,7 +36,7 @@ module RubyEventStore
|
|
36
36
|
transaction do
|
37
37
|
l = get_lock_record(fetch_specification)
|
38
38
|
|
39
|
-
if l.recently_locked?
|
39
|
+
if l.recently_locked?(clock: clock)
|
40
40
|
:taken
|
41
41
|
else
|
42
42
|
l.update!(
|
@@ -89,8 +89,8 @@ module RubyEventStore
|
|
89
89
|
locked_by.eql?(process_uuid)
|
90
90
|
end
|
91
91
|
|
92
|
-
def recently_locked?
|
93
|
-
locked_by && locked_at > RECENTLY_LOCKED_DURATION.ago
|
92
|
+
def recently_locked?(clock:)
|
93
|
+
locked_by && locked_at > RECENTLY_LOCKED_DURATION.ago(clock.now)
|
94
94
|
end
|
95
95
|
|
96
96
|
def fetch_specification
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'sidekiq'
|
4
|
+
require_relative 'sidekiq5_format'
|
4
5
|
require_relative "repository"
|
5
6
|
|
6
7
|
module RubyEventStore
|
@@ -10,7 +11,7 @@ module RubyEventStore
|
|
10
11
|
sidekiq_client = Sidekiq::Client.new(Sidekiq.redis_pool)
|
11
12
|
item = {
|
12
13
|
'class' => klass,
|
13
|
-
'args' => args,
|
14
|
+
'args' => args.map(&:to_h).map {|h| h.transform_keys(&:to_s)},
|
14
15
|
}
|
15
16
|
normalized_item = sidekiq_client.__send__(:normalize_item, item)
|
16
17
|
payload = sidekiq_client.__send__(:process_single, normalized_item.fetch('class'), normalized_item)
|
@@ -5,12 +5,13 @@ require_relative "sidekiq_producer"
|
|
5
5
|
module RubyEventStore
|
6
6
|
module Outbox
|
7
7
|
class SidekiqScheduler
|
8
|
-
def initialize
|
8
|
+
def initialize(serializer: YAML)
|
9
|
+
@serializer = serializer
|
9
10
|
@sidekiq_producer = SidekiqProducer.new
|
10
11
|
end
|
11
12
|
|
12
|
-
def call(klass,
|
13
|
-
sidekiq_producer.call(klass, [
|
13
|
+
def call(klass, record)
|
14
|
+
sidekiq_producer.call(klass, [record.serialize(serializer)])
|
14
15
|
end
|
15
16
|
|
16
17
|
def verify(subscriber)
|
@@ -18,7 +19,7 @@ module RubyEventStore
|
|
18
19
|
end
|
19
20
|
|
20
21
|
private
|
21
|
-
attr_reader :sidekiq_producer
|
22
|
+
attr_reader :serializer, :sidekiq_producer
|
22
23
|
end
|
23
24
|
end
|
24
25
|
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.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arkency
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby_event_store
|
@@ -55,14 +55,14 @@ files:
|
|
55
55
|
- lib/ruby_event_store/outbox/cleanup_strategies/none.rb
|
56
56
|
- lib/ruby_event_store/outbox/cli.rb
|
57
57
|
- lib/ruby_event_store/outbox/consumer.rb
|
58
|
-
- lib/ruby_event_store/outbox/consumer_process.rb
|
59
58
|
- lib/ruby_event_store/outbox/fetch_specification.rb
|
59
|
+
- lib/ruby_event_store/outbox/legacy_sidekiq_scheduler.rb
|
60
60
|
- lib/ruby_event_store/outbox/metrics.rb
|
61
61
|
- lib/ruby_event_store/outbox/metrics/influx.rb
|
62
62
|
- lib/ruby_event_store/outbox/metrics/null.rb
|
63
|
+
- lib/ruby_event_store/outbox/metrics/test.rb
|
63
64
|
- lib/ruby_event_store/outbox/repository.rb
|
64
65
|
- lib/ruby_event_store/outbox/sidekiq5_format.rb
|
65
|
-
- lib/ruby_event_store/outbox/sidekiq_message_handler.rb
|
66
66
|
- lib/ruby_event_store/outbox/sidekiq_processor.rb
|
67
67
|
- lib/ruby_event_store/outbox/sidekiq_producer.rb
|
68
68
|
- lib/ruby_event_store/outbox/sidekiq_scheduler.rb
|
@@ -74,6 +74,7 @@ metadata:
|
|
74
74
|
homepage_uri: https://railseventstore.org
|
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
|
+
rubygems_mfa_required: 'true'
|
77
78
|
post_install_message:
|
78
79
|
rdoc_options: []
|
79
80
|
require_paths:
|
@@ -89,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
90
|
- !ruby/object:Gem::Version
|
90
91
|
version: '0'
|
91
92
|
requirements: []
|
92
|
-
rubygems_version: 3.
|
93
|
+
rubygems_version: 3.1.6
|
93
94
|
signing_key:
|
94
95
|
specification_version: 4
|
95
96
|
summary: Active Record based outbox for Ruby Event Store
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require "sidekiq"
|
2
|
-
|
3
|
-
module RubyEventStore
|
4
|
-
module Outbox
|
5
|
-
class SidekiqMessageHandler
|
6
|
-
def initialize
|
7
|
-
@sidekiq = Sidekiq::Client.new(Sidekiq.redis_pool)
|
8
|
-
end
|
9
|
-
|
10
|
-
def init
|
11
|
-
end
|
12
|
-
|
13
|
-
def handle_one_record(now, record)
|
14
|
-
hash_payload = JSON.parse(record.payload)
|
15
|
-
@sidekiq.__send__(:raw_push, [hash_payload])
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|