rails_event_store 2.3.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b956e083f03d6da44d1f82cdd1662a093b3f9526c846f38832a85f38daa698c7
4
- data.tar.gz: 3a5202592d84ae5a63315b0badc598000c785bdf97f438425f699671da28f340
3
+ metadata.gz: 91f7683035b0f3fc95f87d510ffbcf7f059548a25e507a5ea2fb4a062a335408
4
+ data.tar.gz: 4186181a73a6eca5d4e58821e2a734b9c334d947a09d8941a5ae3ec1d9134572
5
5
  SHA512:
6
- metadata.gz: 39852a4cf687b8965d51fa364e46fff94d4d689f3b0c75ae8abdd84109b38728eb4f4c0fcca076cbadcd54c6f7c41f88a17383311654bee7918a586e3dc17a1b
7
- data.tar.gz: 83e445adc6aa7937b2f535010908bb265fa5ca2d75100b2539e1247a0453e6924fd83065c6c56a960ebd42937e44c13e96742e474d409ea968ec022251050c6f
6
+ metadata.gz: 8c85bcd0e1991ef9c8e061cc817e266a27f75f28c757a23d8cc98f0e1c242e9b59117a4fd465a12d59eb4dbfc7216012de50130e3ee3b0a25426ffecc5cae7a9
7
+ data.tar.gz: 80b902dce3a9c673c81f804f32c456a7b701ec0f1103068246220cceff921836277f7c303037493e60695a0448e86beca1e8a6b4833085c2c1bee9e547650c1b
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 do
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,4 +1,4 @@
1
- require_relative 'spec_helper'
1
+ require_relative "spec_helper"
2
2
 
3
3
  RSpec.describe <%= bounded_context_namespace %> do
4
4
  end
@@ -1,6 +1,4 @@
1
1
  require "rails_helper"
2
2
 
3
3
  path = Rails.root.join("<%= bounded_context_name %>/spec")
4
- Dir.glob("#{path}/**/*_spec.rb") do |file|
5
- require file
6
- end
4
+ Dir.glob("#{path}/**/*_spec.rb") { |file| require file }
@@ -1,7 +1,7 @@
1
- ENV['RAILS_ENV'] = 'test'
1
+ ENV["RAILS_ENV"] = "test"
2
2
 
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__)
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 '../lib/<%= bounded_context_name %>'
7
+ require_relative "../lib/<%= bounded_context_name %>"
@@ -1 +1 @@
1
- require_relative '../lib/<%= bounded_context_name %>'
1
+ require_relative "../lib/<%= bounded_context_name %>"
@@ -17,6 +17,7 @@ module RailsEventStore
17
17
  end
18
18
 
19
19
  private
20
+
20
21
  attr_reader :serializer
21
22
  end
22
23
  end
@@ -7,9 +7,7 @@ module RailsEventStore
7
7
  end
8
8
 
9
9
  def call(subscriber, _, record)
10
- run do
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 = 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
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
- Module.new do
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(event_store: Rails.configuration.event_store, serializer: YAML)
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.configuration.event_store.with_metadata(
29
- correlation_id: event.metadata[:correlation_id],
30
- causation_id: event.event_id
31
- ) do
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,4 +4,4 @@ require "ruby_event_store/browser/app"
4
4
 
5
5
  module RailsEventStore
6
6
  Browser = RubyEventStore::Browser::App.for(event_store_locator: -> { Rails.configuration.event_store })
7
- end
7
+ end
@@ -4,39 +4,41 @@ module RailsEventStore
4
4
  class Client < RubyEventStore::Client
5
5
  attr_reader :request_metadata
6
6
 
7
- def initialize(mapper: RubyEventStore::Mappers::Default.new,
8
- repository: RailsEventStoreActiveRecord::EventRepository.new(serializer: YAML),
9
- subscriptions: RubyEventStore::Subscriptions.new,
10
- dispatcher: RubyEventStore::ComposedDispatcher.new(
11
- RailsEventStore::AfterCommitAsyncDispatcher.new(scheduler: ActiveJobScheduler.new(serializer: YAML)),
12
- RubyEventStore::Dispatcher.new),
13
- clock: default_clock,
14
- correlation_id_generator: default_correlation_id_generator,
15
- request_metadata: default_request_metadata)
16
- super(repository: RubyEventStore::InstrumentedRepository.new(repository, ActiveSupport::Notifications),
17
- mapper: RubyEventStore::Mappers::InstrumentedMapper.new(mapper, ActiveSupport::Notifications),
18
- subscriptions: subscriptions,
19
- clock: clock,
20
- correlation_id_generator: correlation_id_generator,
21
- dispatcher: RubyEventStore::InstrumentedDispatcher.new(dispatcher, ActiveSupport::Notifications)
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)) do
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
@@ -8,9 +8,7 @@ module RailsEventStore
8
8
 
9
9
  def call(env)
10
10
  if config.respond_to?(:event_store)
11
- config.event_store.with_request_metadata(env) do
12
- @app.call(env)
13
- end
11
+ config.event_store.with_request_metadata(env) { @app.call(env) }
14
12
  else
15
13
  @app.call(env)
16
14
  end
@@ -10,4 +10,3 @@ module RailsEventStore
10
10
  end
11
11
  end
12
12
  end
13
-
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsEventStore
4
- VERSION = "2.3.0"
4
+ VERSION = "2.5.0"
5
5
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rails_event_store_active_record"
4
- require_relative "rails_event_store/all"
4
+ require_relative "rails_event_store/all"
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.3.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arkency
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-09 00:00:00.000000000 Z
11
+ date: 2022-06-22 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.3.0
19
+ version: 2.5.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.3.0
26
+ version: 2.5.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.3.0
33
+ version: 2.5.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.3.0
40
+ version: 2.5.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.3.0
47
+ version: 2.5.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.3.0
54
+ version: 2.5.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.3.0
61
+ version: 2.5.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.3.0
68
+ version: 2.5.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.6'
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.1.4
179
+ rubygems_version: 3.3.11
179
180
  signing_key:
180
181
  specification_version: 4
181
182
  summary: Rails wrapper for RubyEventStore with batteries included