rails_event_store 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/generators/rails_event_store/bounded_context_generator.rb +1 -3
- data/lib/generators/templates/bc_spec.rb +1 -1
- data/lib/generators/templates/require_bc_spec.rb +1 -3
- data/lib/generators/templates/spec_helper.rb +5 -5
- data/lib/generators/templates/test_helper.rb +1 -1
- data/lib/rails_event_store/active_job_scheduler.rb +1 -0
- data/lib/rails_event_store/after_commit_async_dispatcher.rb +4 -9
- data/lib/rails_event_store/all.rb +17 -17
- data/lib/rails_event_store/async_handler_helpers.rb +11 -12
- data/lib/rails_event_store/browser.rb +1 -1
- data/lib/rails_event_store/client.rb +25 -23
- data/lib/rails_event_store/link_by_metadata.rb +0 -2
- data/lib/rails_event_store/middleware.rb +1 -3
- data/lib/rails_event_store/railtie.rb +0 -1
- data/lib/rails_event_store/version.rb +1 -1
- data/lib/rails_event_store.rb +1 -1
- metadata +13 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd65cf3d50349141c5bf6696f48a5508494568c1597ae4fda390a9344c7c0b44
|
4
|
+
data.tar.gz: 79d47fa5c8d2de64588d2882c73c0f59020208c3fed7860ebfcbef9c438bb9f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4acfe534d48ddb54671e468845c1fbfa578b4fe98ed722e30853f4f6ce15eadb2083e5498f7bc0fe3de0fc881874f936783aeea9e734c11cdd3381cb82df05f4
|
7
|
+
data.tar.gz: c6bdca195b12d7917ff7bfec294a74d0994049cd4e322b2427f0ebc42517109175ddf08286ee68743b0daec358366437661235719654735eb5d564a1e3c823d1
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# RailsEventStore
|
2
2
|
|
3
|
-
Rails wrapper for RubyEventStore with batteries included.
|
3
|
+
Rails wrapper for RubyEventStore with batteries included.
|
4
4
|
|
5
5
|
Ships with asynchronous after-commit event dispatch on top of ActiveJob, ActiveSupport::Notifications instrumentation enabled, request metadata enrichment and opinionated directory structure generator for bounded contexts.
|
6
6
|
|
@@ -13,9 +13,7 @@ module RailsEventStore
|
|
13
13
|
|
14
14
|
template "module.rb", "#{bounded_context_name}/lib/#{bounded_context_name}.rb"
|
15
15
|
|
16
|
-
application
|
17
|
-
"config.paths.add '#{bounded_context_name}/lib', eager_load: true"
|
18
|
-
end
|
16
|
+
application { "config.paths.add '#{bounded_context_name}/lib', eager_load: true" }
|
19
17
|
end
|
20
18
|
|
21
19
|
private
|
@@ -1,7 +1,7 @@
|
|
1
|
-
ENV[
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
2
|
|
3
|
-
$LOAD_PATH.push File.expand_path(
|
4
|
-
require File.expand_path(
|
5
|
-
require File.expand_path(
|
3
|
+
$LOAD_PATH.push File.expand_path("../../../spec", __FILE__)
|
4
|
+
require File.expand_path("../../../config/environment", __FILE__)
|
5
|
+
require File.expand_path("../../../spec/rails_helper", __FILE__)
|
6
6
|
|
7
|
-
require_relative
|
7
|
+
require_relative "../lib/<%= bounded_context_name %>"
|
@@ -1 +1 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "../lib/<%= bounded_context_name %>"
|
@@ -7,9 +7,7 @@ module RailsEventStore
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call(subscriber, _, record)
|
10
|
-
run
|
11
|
-
@scheduler.call(subscriber, record)
|
12
|
-
end
|
10
|
+
run { @scheduler.call(subscriber, record) }
|
13
11
|
end
|
14
12
|
|
15
13
|
def run(&schedule_proc)
|
@@ -40,18 +38,15 @@ module RailsEventStore
|
|
40
38
|
schedule_proc.call
|
41
39
|
end
|
42
40
|
|
43
|
-
def rolledback!(*)
|
44
|
-
end
|
41
|
+
def rolledback!(*); end
|
45
42
|
|
46
|
-
def before_committed
|
47
|
-
end
|
43
|
+
def before_committed!; end
|
48
44
|
|
49
45
|
def add_to_transaction
|
50
46
|
dispatcher.run(&schedule_proc)
|
51
47
|
end
|
52
48
|
|
53
|
-
def trigger_transactional_callbacks
|
54
|
-
end
|
49
|
+
def trigger_transactional_callbacks?; end
|
55
50
|
|
56
51
|
attr_reader :schedule_proc, :dispatcher
|
57
52
|
end
|
@@ -11,21 +11,21 @@ require_relative "railtie"
|
|
11
11
|
require_relative "browser"
|
12
12
|
|
13
13
|
module RailsEventStore
|
14
|
-
Event
|
15
|
-
InMemoryRepository
|
16
|
-
Subscriptions
|
17
|
-
Projection
|
18
|
-
WrongExpectedEventVersion
|
19
|
-
InvalidExpectedVersion
|
20
|
-
IncorrectStreamData
|
21
|
-
EventNotFound
|
22
|
-
SubscriberNotExist
|
23
|
-
InvalidHandler
|
24
|
-
InvalidPageStart
|
25
|
-
InvalidPageStop
|
26
|
-
InvalidPageSize
|
27
|
-
CorrelatedCommands
|
28
|
-
GLOBAL_STREAM
|
29
|
-
PAGE_SIZE
|
30
|
-
ImmediateAsyncDispatcher
|
14
|
+
Event = RubyEventStore::Event
|
15
|
+
InMemoryRepository = RubyEventStore::InMemoryRepository
|
16
|
+
Subscriptions = RubyEventStore::Subscriptions
|
17
|
+
Projection = RubyEventStore::Projection
|
18
|
+
WrongExpectedEventVersion = RubyEventStore::WrongExpectedEventVersion
|
19
|
+
InvalidExpectedVersion = RubyEventStore::InvalidExpectedVersion
|
20
|
+
IncorrectStreamData = RubyEventStore::IncorrectStreamData
|
21
|
+
EventNotFound = RubyEventStore::EventNotFound
|
22
|
+
SubscriberNotExist = RubyEventStore::SubscriberNotExist
|
23
|
+
InvalidHandler = RubyEventStore::InvalidHandler
|
24
|
+
InvalidPageStart = RubyEventStore::InvalidPageStart
|
25
|
+
InvalidPageStop = RubyEventStore::InvalidPageStop
|
26
|
+
InvalidPageSize = RubyEventStore::InvalidPageSize
|
27
|
+
CorrelatedCommands = RubyEventStore::CorrelatedCommands
|
28
|
+
GLOBAL_STREAM = RubyEventStore::GLOBAL_STREAM
|
29
|
+
PAGE_SIZE = RubyEventStore::PAGE_SIZE
|
30
|
+
ImmediateAsyncDispatcher = RubyEventStore::ImmediateAsyncDispatcher
|
31
31
|
end
|
@@ -3,16 +3,17 @@
|
|
3
3
|
module RailsEventStore
|
4
4
|
module AsyncHandler
|
5
5
|
def self.with_defaults
|
6
|
-
|
7
|
-
def self.prepended(host_class)
|
8
|
-
host_class.prepend AsyncHandler.with
|
9
|
-
end
|
10
|
-
end
|
6
|
+
with
|
11
7
|
end
|
12
8
|
|
13
|
-
def self.with(
|
9
|
+
def self.with(
|
10
|
+
event_store: Rails.configuration.event_store,
|
11
|
+
event_store_locator: nil,
|
12
|
+
serializer: RubyEventStore::Serializers::YAML
|
13
|
+
)
|
14
14
|
Module.new do
|
15
15
|
define_method :perform do |payload|
|
16
|
+
event_store = event_store_locator.call if event_store_locator
|
16
17
|
super(event_store.deserialize(serializer: serializer, **payload.symbolize_keys))
|
17
18
|
end
|
18
19
|
end
|
@@ -25,12 +26,10 @@ module RailsEventStore
|
|
25
26
|
|
26
27
|
module CorrelatedHandler
|
27
28
|
def perform(event)
|
28
|
-
Rails
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
super
|
33
|
-
end
|
29
|
+
Rails
|
30
|
+
.configuration
|
31
|
+
.event_store
|
32
|
+
.with_metadata(correlation_id: event.metadata[:correlation_id], causation_id: event.event_id) { super }
|
34
33
|
end
|
35
34
|
end
|
36
35
|
end
|
@@ -4,39 +4,41 @@ module RailsEventStore
|
|
4
4
|
class Client < RubyEventStore::Client
|
5
5
|
attr_reader :request_metadata
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
7
|
+
def initialize(
|
8
|
+
mapper: RubyEventStore::Mappers::Default.new,
|
9
|
+
repository: RailsEventStoreActiveRecord::EventRepository.new(serializer: RubyEventStore::Serializers::YAML),
|
10
|
+
subscriptions: RubyEventStore::Subscriptions.new,
|
11
|
+
dispatcher: RubyEventStore::ComposedDispatcher.new(
|
12
|
+
RailsEventStore::AfterCommitAsyncDispatcher.new(
|
13
|
+
scheduler: ActiveJobScheduler.new(serializer: RubyEventStore::Serializers::YAML)
|
14
|
+
),
|
15
|
+
RubyEventStore::Dispatcher.new
|
16
|
+
),
|
17
|
+
clock: default_clock,
|
18
|
+
correlation_id_generator: default_correlation_id_generator,
|
19
|
+
request_metadata: default_request_metadata
|
20
|
+
)
|
21
|
+
super(
|
22
|
+
repository: RubyEventStore::InstrumentedRepository.new(repository, ActiveSupport::Notifications),
|
23
|
+
mapper: RubyEventStore::Mappers::InstrumentedMapper.new(mapper, ActiveSupport::Notifications),
|
24
|
+
subscriptions: subscriptions,
|
25
|
+
clock: clock,
|
26
|
+
correlation_id_generator: correlation_id_generator,
|
27
|
+
dispatcher: RubyEventStore::InstrumentedDispatcher.new(dispatcher, ActiveSupport::Notifications)
|
28
|
+
)
|
23
29
|
@request_metadata = request_metadata
|
24
30
|
end
|
25
31
|
|
26
32
|
def with_request_metadata(env, &block)
|
27
|
-
with_metadata(request_metadata.call(env))
|
28
|
-
block.call
|
29
|
-
end
|
33
|
+
with_metadata(request_metadata.call(env)) { block.call }
|
30
34
|
end
|
31
35
|
|
32
36
|
private
|
37
|
+
|
33
38
|
def default_request_metadata
|
34
39
|
->(env) do
|
35
40
|
request = ActionDispatch::Request.new(env)
|
36
|
-
{
|
37
|
-
remote_ip: request.remote_ip,
|
38
|
-
request_id: request.uuid
|
39
|
-
}
|
41
|
+
{ remote_ip: request.remote_ip, request_id: request.uuid }
|
40
42
|
end
|
41
43
|
end
|
42
44
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module RailsEventStore
|
4
|
-
|
5
4
|
class LinkByMetadata < RubyEventStore::LinkByMetadata
|
6
5
|
def initialize(event_store: Rails.configuration.event_store, key:, prefix: nil)
|
7
6
|
super
|
@@ -25,5 +24,4 @@ module RailsEventStore
|
|
25
24
|
super
|
26
25
|
end
|
27
26
|
end
|
28
|
-
|
29
27
|
end
|
data/lib/rails_event_store.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_event_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
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-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby_event_store
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.4.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.4.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: ruby_event_store-browser
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: 2.4.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.
|
40
|
+
version: 2.4.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rails_event_store_active_record
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.
|
47
|
+
version: 2.4.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
54
|
+
version: 2.4.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: aggregate_root
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.
|
61
|
+
version: 2.4.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.
|
68
|
+
version: 2.4.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: activesupport
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,6 +160,7 @@ metadata:
|
|
160
160
|
changelog_uri: https://github.com/RailsEventStore/rails_event_store/releases
|
161
161
|
source_code_uri: https://github.com/RailsEventStore/rails_event_store
|
162
162
|
bug_tracker_uri: https://github.com/RailsEventStore/rails_event_store/issues
|
163
|
+
rubygems_mfa_required: 'true'
|
163
164
|
post_install_message:
|
164
165
|
rdoc_options: []
|
165
166
|
require_paths:
|
@@ -168,14 +169,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
168
169
|
requirements:
|
169
170
|
- - ">="
|
170
171
|
- !ruby/object:Gem::Version
|
171
|
-
version: '2.
|
172
|
+
version: '2.7'
|
172
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
174
|
requirements:
|
174
175
|
- - ">="
|
175
176
|
- !ruby/object:Gem::Version
|
176
177
|
version: '0'
|
177
178
|
requirements: []
|
178
|
-
rubygems_version: 3.
|
179
|
+
rubygems_version: 3.3.7
|
179
180
|
signing_key:
|
180
181
|
specification_version: 4
|
181
182
|
summary: Rails wrapper for RubyEventStore with batteries included
|