rails_event_store 2.15.0 → 2.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46579edfa4a2949327246ee1752cdee115cbbcf3ce32957f612b9c192961ee0d
4
- data.tar.gz: f51139771d2e5b0df40c90b18d3c4c3855d98305d302e34dc9bd3172732c5258
3
+ metadata.gz: bcf4331ca95c4367a205cd887ab2dbbd72fb6871942d747c50f0459dc486268f
4
+ data.tar.gz: 548b8e0272378cc3ea5f0295c164ea1fe930491636d2f3fd0892e9b693cad45b
5
5
  SHA512:
6
- metadata.gz: c4cebfaa78585fa0256761a3f1aa5d379e38e5b5c3eac9f913320a4ae9d605d08da0f2e90e425c103212a170d93d1b3de02ec36dadd37ff46037cbb67ed651aa
7
- data.tar.gz: 8985fcefd9823fd3e93b87ee7e61a8c6eb44225fc4a5c6f3d0a2a6e7991fd140f3f7cf8e70891fb33e3f46e0725f3d1c4fd673a3532820d235d319074b56475b
6
+ metadata.gz: 8eeb81eaa66884a4139f34bd737de32469c3e1bbb76b63935bbd383135379537427b26684cc951548fbee0a5a0b6cb339d67ae78a693b9d643658b9483f4997d
7
+ data.tar.gz: e4fa1bc07d76f0170ed2ed993cd0ba7edb48a5790d226ea0a88ec750689d719cb61d33b7d5856bf4fc039e44b4eed5026919fca84d35d4c6bbaa07b023295ad5
@@ -11,7 +11,7 @@ module RailsEventStore
11
11
  def create_bounded_context
12
12
  create_file "#{bounded_context_name}/lib/#{bounded_context_name}/.keep"
13
13
 
14
- template "module.rb", "#{bounded_context_name}/lib/#{bounded_context_name}.rb"
14
+ template "module.erb", "#{bounded_context_name}/lib/#{bounded_context_name}.rb"
15
15
 
16
16
  application { "config.paths.add '#{bounded_context_name}/lib', eager_load: true" }
17
17
  end
@@ -8,15 +8,15 @@ module RailsEventStore
8
8
  source_root File.expand_path(File.join(File.dirname(__FILE__), "../templates"))
9
9
 
10
10
  def spec_helper
11
- template "spec_helper.rb", "#{bounded_context_name}/spec/spec_helper.rb"
11
+ template "spec_helper.erb", "#{bounded_context_name}/spec/spec_helper.rb"
12
12
  end
13
13
 
14
14
  def bc_spec
15
- template "bc_spec.rb", "#{bounded_context_name}/spec/#{bounded_context_name}_spec.rb"
15
+ template "bc_spec.erb", "#{bounded_context_name}/spec/#{bounded_context_name}_spec.rb"
16
16
  end
17
17
 
18
18
  def require_bc_spec
19
- template "require_bc_spec.rb", "spec/#{bounded_context_name}_spec.rb"
19
+ template "require_bc_spec.erb", "spec/#{bounded_context_name}_spec.rb"
20
20
  end
21
21
 
22
22
  private
@@ -8,11 +8,11 @@ module RailsEventStore
8
8
  source_root File.expand_path(File.join(File.dirname(__FILE__), "../templates"))
9
9
 
10
10
  def test_helper
11
- template "test_helper.rb", "#{bounded_context_name}/test/test_helper.rb"
11
+ template "test_helper.erb", "#{bounded_context_name}/test/test_helper.rb"
12
12
  end
13
13
 
14
14
  def require_bc_test
15
- template "require_bc_test.rb", "test/#{bounded_context_name}_test.rb"
15
+ template "require_bc_test.erb", "test/#{bounded_context_name}_test.rb"
16
16
  end
17
17
 
18
18
  private
@@ -37,11 +37,14 @@ module RailsEventStore
37
37
  schedule_proc.call
38
38
  end
39
39
 
40
- def rolledback!(*); end
40
+ def rolledback!(*)
41
+ end
41
42
 
42
- def before_committed!; end
43
+ def before_committed!
44
+ end
43
45
 
44
- def trigger_transactional_callbacks?; end
46
+ def trigger_transactional_callbacks?
47
+ end
45
48
 
46
49
  attr_reader :schedule_proc
47
50
  end
@@ -5,7 +5,7 @@ require_relative "async_handler_helpers"
5
5
  require_relative "link_by_metadata"
6
6
  require_relative "after_commit_async_dispatcher"
7
7
  require_relative "active_job_scheduler"
8
- require_relative 'active_job_id_only_scheduler'
8
+ require_relative "active_job_id_only_scheduler"
9
9
  require_relative "client"
10
10
  require_relative "json_client"
11
11
  require_relative "version"
@@ -13,8 +13,12 @@ module RailsEventStore
13
13
  )
14
14
  Module.new do
15
15
  define_method :perform do |payload|
16
- event_store = event_store_locator.call if event_store_locator
17
- super(event_store.deserialize(serializer: serializer, **payload.transform_keys(&:to_sym)))
16
+ if Hash === payload
17
+ event_store = event_store_locator.call if event_store_locator
18
+ super(event_store.deserialize(serializer: serializer, **payload.transform_keys(&:to_sym)))
19
+ else
20
+ super(payload)
21
+ end
18
22
  end
19
23
  end
20
24
  end
@@ -29,10 +33,7 @@ module RailsEventStore
29
33
  with
30
34
  end
31
35
 
32
- def self.with(
33
- event_store: Rails.configuration.event_store,
34
- event_store_locator: nil
35
- )
36
+ def self.with(event_store: Rails.configuration.event_store, event_store_locator: nil)
36
37
  Module.new do
37
38
  define_method :perform do |payload|
38
39
  event_store = event_store_locator.call if event_store_locator
@@ -46,7 +47,6 @@ module RailsEventStore
46
47
  end
47
48
  end
48
49
 
49
-
50
50
  module CorrelatedHandler
51
51
  def perform(event)
52
52
  Rails
@@ -5,28 +5,80 @@ module RailsEventStore
5
5
  attr_reader :request_metadata
6
6
 
7
7
  def initialize(
8
- mapper: RubyEventStore::Mappers::Default.new,
8
+ mapper: RubyEventStore::Mappers::BatchMapper.new,
9
9
  repository: RubyEventStore::ActiveRecord::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
- ),
10
+ subscriptions: nil,
11
+ dispatcher: nil,
12
+ message_broker: nil,
17
13
  clock: default_clock,
18
14
  correlation_id_generator: default_correlation_id_generator,
19
15
  request_metadata: default_request_metadata
20
16
  )
21
17
  super(
22
18
  repository: RubyEventStore::InstrumentedRepository.new(repository, ActiveSupport::Notifications),
23
- mapper: RubyEventStore::Mappers::InstrumentedMapper.new(mapper, ActiveSupport::Notifications),
24
- subscriptions: RubyEventStore::InstrumentedSubscriptions.new(subscriptions, ActiveSupport::Notifications),
19
+ mapper:
20
+ (
21
+ if batch_mapper?(mapper)
22
+ RubyEventStore::Mappers::InstrumentedBatchMapper.new(mapper, ActiveSupport::Notifications)
23
+ else
24
+ RubyEventStore::Mappers::InstrumentedMapper.new(mapper, ActiveSupport::Notifications)
25
+ end
26
+ ),
27
+ subscriptions: nil,
25
28
  clock: clock,
26
29
  correlation_id_generator: correlation_id_generator,
27
- dispatcher: RubyEventStore::InstrumentedDispatcher.new(dispatcher, ActiveSupport::Notifications)
30
+ dispatcher: nil,
31
+ message_broker:
32
+ RubyEventStore::InstrumentedBroker.new(
33
+ message_broker ||
34
+ RubyEventStore::Broker.new(
35
+ subscriptions:
36
+ RubyEventStore::InstrumentedSubscriptions.new(
37
+ subscriptions || RubyEventStore::Subscriptions.new,
38
+ ActiveSupport::Notifications,
39
+ ),
40
+ dispatcher:
41
+ RubyEventStore::InstrumentedDispatcher.new(
42
+ dispatcher ||
43
+ RubyEventStore::ComposedDispatcher.new(
44
+ RailsEventStore::AfterCommitAsyncDispatcher.new(
45
+ scheduler: ActiveJobScheduler.new(serializer: RubyEventStore::Serializers::YAML),
46
+ ),
47
+ RubyEventStore::Dispatcher.new,
48
+ ),
49
+ ActiveSupport::Notifications,
50
+ ),
51
+ ),
52
+ ActiveSupport::Notifications,
53
+ ),
28
54
  )
29
55
  @request_metadata = request_metadata
56
+
57
+ if (subscriptions || dispatcher)
58
+ warn <<~EOW
59
+ Passing subscriptions and dispatcher to #{self.class} has been deprecated.
60
+
61
+ Pass it using message_broker argument. For example:
62
+
63
+ event_store = #{self.class}.new(
64
+ message_broker: RubyEventStore::Broker.new(
65
+ subscriptions: RubyEventStore::Subscriptions.new,
66
+ dispatcher: RubyEventStore::ComposedDispatcher.new(
67
+ RailsEventStore::AfterCommitAsyncDispatcher.new(
68
+ scheduler: RailsEventStore::ActiveJobScheduler.new(serializer: RubyEventStore::Serializers::YAML)
69
+ ),
70
+ RubyEventStore::Dispatcher.new
71
+ )
72
+ )
73
+ )
74
+ EOW
75
+
76
+ warn <<~EOW if (message_broker)
77
+
78
+ Because message_broker has been provided,
79
+ arguments passed by subscriptions or dispatcher will be ignored.
80
+ EOW
81
+ end
30
82
  end
31
83
 
32
84
  def with_request_metadata(env, &block)
@@ -1,53 +1,62 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "json"
4
+
3
5
  module RailsEventStore
4
6
  class JSONClient < Client
5
7
  def initialize(
6
- mapper:
8
+ mapper: RubyEventStore::Mappers::BatchMapper.new(
7
9
  RubyEventStore::Mappers::PipelineMapper.new(
8
10
  RubyEventStore::Mappers::Pipeline.new(
9
- RubyEventStore::Mappers::Transformation::PreserveTypes
10
- .new
11
- .register(Symbol, serializer: ->(v) { v.to_s }, deserializer: ->(v) { v.to_sym })
12
- .register(
13
- Time,
11
+ {
12
+ Symbol => {
13
+ serializer: ->(v) { v.to_s },
14
+ deserializer: ->(v) { v.to_sym },
15
+ },
16
+ Time => {
14
17
  serializer: ->(v) { v.iso8601(RubyEventStore::TIMESTAMP_PRECISION) },
15
- deserializer: ->(v) { Time.iso8601(v) }
16
- )
17
- .register(
18
- ActiveSupport::TimeWithZone,
18
+ deserializer: ->(v) { Time.iso8601(v) },
19
+ },
20
+ ActiveSupport::TimeWithZone => {
19
21
  serializer: ->(v) { v.iso8601(RubyEventStore::TIMESTAMP_PRECISION) },
20
22
  deserializer: ->(v) { Time.iso8601(v).in_time_zone },
21
- stored_type: ->(*) { "ActiveSupport::TimeWithZone" }
22
- )
23
- .register(Date, serializer: ->(v) { v.iso8601 }, deserializer: ->(v) { Date.iso8601(v) })
24
- .register(DateTime, serializer: ->(v) { v.iso8601 }, deserializer: ->(v) { DateTime.iso8601(v) })
25
- .register(BigDecimal, serializer: ->(v) { v.to_s }, deserializer: ->(v) { BigDecimal(v) })
26
- .register(OpenStruct, serializer: ->(v) { v.to_h }, deserializer: ->(v) { OpenStruct.new(v) }),
27
- RubyEventStore::Mappers::Transformation::SymbolizeMetadataKeys.new
28
- )
29
- ),
30
- repository: RubyEventStore::ActiveRecord::EventRepository.new(serializer: RubyEventStore::NULL),
31
- subscriptions: RubyEventStore::Subscriptions.new,
32
- dispatcher: RubyEventStore::ComposedDispatcher.new(
33
- RailsEventStore::AfterCommitAsyncDispatcher.new(
34
- scheduler: ActiveJobScheduler.new(serializer: RubyEventStore::Serializers::YAML)
23
+ stored_type: ->(*) { "ActiveSupport::TimeWithZone" },
24
+ },
25
+ Date => {
26
+ serializer: ->(v) { v.iso8601 },
27
+ deserializer: ->(v) { Date.iso8601(v) },
28
+ },
29
+ DateTime => {
30
+ serializer: ->(v) { v.iso8601 },
31
+ deserializer: ->(v) { DateTime.iso8601(v) },
32
+ },
33
+ BigDecimal => {
34
+ serializer: ->(v) { v.to_s },
35
+ deserializer: ->(v) { BigDecimal(v) },
36
+ },
37
+ }.merge(
38
+ if defined?(OpenStruct)
39
+ { OpenStruct => { serializer: ->(v) { v.to_h }, deserializer: ->(v) { OpenStruct.new(v) } } }
40
+ else
41
+ {}
42
+ end,
43
+ )
44
+ .reduce(RubyEventStore::Mappers::Transformation::PreserveTypes.new) do |preserve_types, (klass, options)|
45
+ preserve_types.register(klass, **options)
46
+ end,
47
+ RubyEventStore::Mappers::Transformation::SymbolizeMetadataKeys.new,
48
+ ),
35
49
  ),
36
- RubyEventStore::Dispatcher.new
37
50
  ),
51
+ repository: RubyEventStore::ActiveRecord::EventRepository.new(serializer: JSON),
52
+ subscriptions: nil,
53
+ dispatcher: nil,
54
+ message_broker: nil,
38
55
  clock: default_clock,
39
56
  correlation_id_generator: default_correlation_id_generator,
40
57
  request_metadata: default_request_metadata
41
58
  )
42
- super(
43
- mapper: RubyEventStore::Mappers::InstrumentedMapper.new(mapper, ActiveSupport::Notifications),
44
- repository: RubyEventStore::InstrumentedRepository.new(repository, ActiveSupport::Notifications),
45
- subscriptions: RubyEventStore::InstrumentedSubscriptions.new(subscriptions, ActiveSupport::Notifications),
46
- clock: clock,
47
- correlation_id_generator: correlation_id_generator,
48
- dispatcher: RubyEventStore::InstrumentedDispatcher.new(dispatcher, ActiveSupport::Notifications)
49
- )
50
- @request_metadata = request_metadata
59
+ super
51
60
  end
52
61
  end
53
62
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsEventStore
4
- VERSION = "2.15.0"
4
+ VERSION = "2.17.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_event_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.15.0
4
+ version: 2.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arkency
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-08-09 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: ruby_event_store
@@ -16,56 +15,56 @@ dependencies:
16
15
  requirements:
17
16
  - - '='
18
17
  - !ruby/object:Gem::Version
19
- version: 2.15.0
18
+ version: 2.17.0
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - '='
25
24
  - !ruby/object:Gem::Version
26
- version: 2.15.0
25
+ version: 2.17.0
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: ruby_event_store-browser
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - '='
32
31
  - !ruby/object:Gem::Version
33
- version: 2.15.0
32
+ version: 2.17.0
34
33
  type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - '='
39
38
  - !ruby/object:Gem::Version
40
- version: 2.15.0
39
+ version: 2.17.0
41
40
  - !ruby/object:Gem::Dependency
42
41
  name: rails_event_store_active_record
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
44
  - - '='
46
45
  - !ruby/object:Gem::Version
47
- version: 2.15.0
46
+ version: 2.17.0
48
47
  type: :runtime
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
51
  - - '='
53
52
  - !ruby/object:Gem::Version
54
- version: 2.15.0
53
+ version: 2.17.0
55
54
  - !ruby/object:Gem::Dependency
56
55
  name: aggregate_root
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
58
  - - '='
60
59
  - !ruby/object:Gem::Version
61
- version: 2.15.0
60
+ version: 2.17.0
62
61
  type: :runtime
63
62
  prerelease: false
64
63
  version_requirements: !ruby/object:Gem::Requirement
65
64
  requirements:
66
65
  - - '='
67
66
  - !ruby/object:Gem::Version
68
- version: 2.15.0
67
+ version: 2.17.0
69
68
  - !ruby/object:Gem::Dependency
70
69
  name: activesupport
71
70
  requirement: !ruby/object:Gem::Requirement
@@ -136,12 +135,12 @@ files:
136
135
  - lib/generators/rails_event_store/bounded_context_generator.rb
137
136
  - lib/generators/rails_event_store/rspec_generator.rb
138
137
  - lib/generators/rails_event_store/test_unit_generator.rb
139
- - lib/generators/templates/bc_spec.rb
140
- - lib/generators/templates/module.rb
141
- - lib/generators/templates/require_bc_spec.rb
142
- - lib/generators/templates/require_bc_test.rb
143
- - lib/generators/templates/spec_helper.rb
144
- - lib/generators/templates/test_helper.rb
138
+ - lib/generators/templates/bc_spec.erb
139
+ - lib/generators/templates/module.erb
140
+ - lib/generators/templates/require_bc_spec.erb
141
+ - lib/generators/templates/require_bc_test.erb
142
+ - lib/generators/templates/spec_helper.erb
143
+ - lib/generators/templates/test_helper.erb
145
144
  - lib/rails_event_store.rb
146
145
  - lib/rails_event_store/active_job_id_only_scheduler.rb
147
146
  - lib/rails_event_store/active_job_scheduler.rb
@@ -164,7 +163,6 @@ metadata:
164
163
  source_code_uri: https://github.com/RailsEventStore/rails_event_store
165
164
  bug_tracker_uri: https://github.com/RailsEventStore/rails_event_store/issues
166
165
  rubygems_mfa_required: 'true'
167
- post_install_message:
168
166
  rdoc_options: []
169
167
  require_paths:
170
168
  - lib
@@ -179,8 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
177
  - !ruby/object:Gem::Version
180
178
  version: '0'
181
179
  requirements: []
182
- rubygems_version: 3.4.1
183
- signing_key:
180
+ rubygems_version: 3.6.9
184
181
  specification_version: 4
185
182
  summary: Rails wrapper for RubyEventStore with batteries included
186
183
  test_files: []
File without changes