rails_event_store 2.2.0 → 2.4.1
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 +3 -5
- data/lib/generators/rails_event_store/rspec_generator.rb +2 -2
- data/lib/generators/rails_event_store/test_unit_generator.rb +2 -2
- data/lib/generators/templates/bc_spec.rb +1 -1
- data/lib/generators/templates/require_bc_spec.rb +3 -5
- 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 +2 -1
- data/lib/rails_event_store/after_commit_async_dispatcher.rb +4 -9
- data/lib/rails_event_store/all.rb +26 -26
- data/lib/rails_event_store/async_handler_helpers.rb +11 -12
- data/lib/rails_event_store/browser.rb +2 -2
- 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 +3 -4
- data/lib/rails_event_store/version.rb +1 -1
- data/lib/rails_event_store.rb +2 -2
- 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: f1418d4422a8b6c3b5836ea2c5a7e61fb564de67079fcde3c192bf0e3198ab1f
|
4
|
+
data.tar.gz: 3c7119c7fd135d565e824e49e49771e045fe4f51ee5fa9f2ccf927e96ae57806
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07eaef91c2bc13d0203cede7ee97822951bb1c27bb2732ce3c19f6bf4ae122019af5a6a8f7c5df10431a96a21d34ba4744beced847ee4f8aef193169aa0ed665
|
7
|
+
data.tar.gz: 0a9a7629f3fad6a45d09831bfe8233ded2f38be735b198405573e7652df8bbd277a93874e279fdfcc9008f9102a090a49088bb5060c817afd86bf016f29772ad
|
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
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "rails/generators"
|
4
4
|
|
5
5
|
module RailsEventStore
|
6
6
|
module Generators
|
7
7
|
class BoundedContextGenerator < Rails::Generators::NamedBase
|
8
|
-
source_root File.expand_path(File.join(File.dirname(__FILE__),
|
8
|
+
source_root File.expand_path(File.join(File.dirname(__FILE__), "../templates"))
|
9
9
|
hook_for :test_framework
|
10
10
|
|
11
11
|
def create_bounded_context
|
@@ -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,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "rails/generators"
|
4
4
|
|
5
5
|
module RailsEventStore
|
6
6
|
module Generators
|
7
7
|
class RspecGenerator < Rails::Generators::NamedBase
|
8
|
-
source_root File.expand_path(File.join(File.dirname(__FILE__),
|
8
|
+
source_root File.expand_path(File.join(File.dirname(__FILE__), "../templates"))
|
9
9
|
|
10
10
|
def spec_helper
|
11
11
|
template "spec_helper.rb", "#{bounded_context_name}/spec/spec_helper.rb"
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "rails/generators"
|
4
4
|
|
5
5
|
module RailsEventStore
|
6
6
|
module Generators
|
7
7
|
class TestUnitGenerator < Rails::Generators::NamedBase
|
8
|
-
source_root File.expand_path(File.join(File.dirname(__FILE__),
|
8
|
+
source_root File.expand_path(File.join(File.dirname(__FILE__), "../templates"))
|
9
9
|
|
10
10
|
def test_helper
|
11
11
|
template "test_helper.rb", "#{bounded_context_name}/test/test_helper.rb"
|
@@ -1,6 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "rails_helper"
|
2
2
|
|
3
|
-
path = Rails.root.join(
|
4
|
-
Dir.glob("#{path}/**/*_spec.rb")
|
5
|
-
require file
|
6
|
-
end
|
3
|
+
path = Rails.root.join("<%= bounded_context_name %>/spec")
|
4
|
+
Dir.glob("#{path}/**/*_spec.rb") { |file| require file }
|
@@ -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
|
@@ -1,31 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
7
|
-
require_relative
|
8
|
-
require_relative
|
9
|
-
require_relative
|
10
|
-
require_relative
|
11
|
-
require_relative
|
3
|
+
require "ruby_event_store"
|
4
|
+
require_relative "async_handler_helpers"
|
5
|
+
require_relative "link_by_metadata"
|
6
|
+
require_relative "after_commit_async_dispatcher"
|
7
|
+
require_relative "active_job_scheduler"
|
8
|
+
require_relative "client"
|
9
|
+
require_relative "version"
|
10
|
+
require_relative "railtie"
|
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
|
@@ -1,13 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require_relative
|
3
|
+
require "rails/railtie"
|
4
|
+
require_relative "middleware"
|
5
5
|
|
6
6
|
module RailsEventStore
|
7
7
|
class Railtie < ::Rails::Railtie
|
8
|
-
initializer
|
8
|
+
initializer "rails_event_store.middleware" do |rails|
|
9
9
|
rails.middleware.use(::RailsEventStore::Middleware)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
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.1
|
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-28 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.1
|
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.1
|
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.1
|
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.1
|
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.1
|
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.1
|
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.1
|
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.1
|
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
|