ruby_event_store 2.1.0 → 2.2.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: 88203a9b943002241df25fa83c6f067e7944810e66d713eeb11e8cebf13271e2
4
- data.tar.gz: 1b032e898517d787a2e6d0cb6b15775792591abc094e68d2483590f916e69c9e
3
+ metadata.gz: 28fef13a18c820b5e2e67ffef0aa6ee04b171a427fe9f7a9a4323dbab9db61bb
4
+ data.tar.gz: 8aa4bcf65629ae5e1912651d08be52de870f0dc0c274bd046796400d6a50bf34
5
5
  SHA512:
6
- metadata.gz: 780c9e0f6064311d45be29c0553c47e65e679a3967b91e6caca48a55ef9c34a06070e421b1413c1a35634c6e45c1452204ac29fae2aa706fe7a0e46d1dd99f40
7
- data.tar.gz: 66b7a11ce2d3b58a5f9c2690a7f7f998fc9130c302343923cdd5a57a63d6a398ea258cced2d1b3161e07d9fb081d04bd7c4f305d6576cae59bd6e50f50ba6a92
6
+ metadata.gz: 2717723ff31551edb75469a884d88a5e64f97432f218a54c71fe84245bdd91ff770215bd54b90a2ee5dd56054a6bba29ed4ed766c551bb7d7c6f66806f23e207
7
+ data.tar.gz: 4f509c7e557271f414aad29db6dd04063aa9d29a45a49985fb12e89192e88d5bee5c8ad73a561faad3d196e04c4ff3ad2f1471ea3f67f0bd63f54060518cac27
@@ -1,45 +1,45 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ruby_event_store/dispatcher'
4
- require 'ruby_event_store/subscriptions'
5
- require 'ruby_event_store/broker'
6
- require 'ruby_event_store/in_memory_repository'
7
- require 'ruby_event_store/projection'
8
- require 'ruby_event_store/errors'
9
- require 'ruby_event_store/constants'
10
- require 'ruby_event_store/client'
11
- require 'ruby_event_store/metadata'
12
- require 'ruby_event_store/specification'
13
- require 'ruby_event_store/specification_result'
14
- require 'ruby_event_store/specification_reader'
15
- require 'ruby_event_store/event'
16
- require 'ruby_event_store/stream'
17
- require 'ruby_event_store/expected_version'
18
- require 'ruby_event_store/record'
19
- require 'ruby_event_store/serialized_record'
20
- require 'ruby_event_store/null'
21
- require 'ruby_event_store/transform_keys'
22
- require 'ruby_event_store/mappers/encryption_key'
23
- require 'ruby_event_store/mappers/in_memory_encryption_key_repository'
24
- require 'ruby_event_store/mappers/transformation/domain_event'
25
- require 'ruby_event_store/mappers/transformation/encryption'
26
- require 'ruby_event_store/mappers/transformation/event_class_remapper'
27
- require 'ruby_event_store/mappers/transformation/upcast'
28
- require 'ruby_event_store/mappers/transformation/stringify_metadata_keys'
29
- require 'ruby_event_store/mappers/transformation/symbolize_metadata_keys'
30
- require 'ruby_event_store/mappers/pipeline'
31
- require 'ruby_event_store/mappers/pipeline_mapper'
32
- require 'ruby_event_store/mappers/default'
33
- require 'ruby_event_store/mappers/forgotten_data'
34
- require 'ruby_event_store/mappers/encryption_mapper'
35
- require 'ruby_event_store/mappers/instrumented_mapper'
36
- require 'ruby_event_store/mappers/json_mapper'
37
- require 'ruby_event_store/mappers/null_mapper'
38
- require 'ruby_event_store/batch_enumerator'
39
- require 'ruby_event_store/correlated_commands'
40
- require 'ruby_event_store/link_by_metadata'
41
- require 'ruby_event_store/immediate_async_dispatcher'
42
- require 'ruby_event_store/composed_dispatcher'
43
- require 'ruby_event_store/version'
44
- require 'ruby_event_store/instrumented_repository'
45
- require 'ruby_event_store/instrumented_dispatcher'
3
+ require_relative 'ruby_event_store/dispatcher'
4
+ require_relative 'ruby_event_store/subscriptions'
5
+ require_relative 'ruby_event_store/broker'
6
+ require_relative 'ruby_event_store/in_memory_repository'
7
+ require_relative 'ruby_event_store/projection'
8
+ require_relative 'ruby_event_store/errors'
9
+ require_relative 'ruby_event_store/constants'
10
+ require_relative 'ruby_event_store/client'
11
+ require_relative 'ruby_event_store/metadata'
12
+ require_relative 'ruby_event_store/specification'
13
+ require_relative 'ruby_event_store/specification_result'
14
+ require_relative 'ruby_event_store/specification_reader'
15
+ require_relative 'ruby_event_store/event'
16
+ require_relative 'ruby_event_store/stream'
17
+ require_relative 'ruby_event_store/expected_version'
18
+ require_relative 'ruby_event_store/record'
19
+ require_relative 'ruby_event_store/serialized_record'
20
+ require_relative 'ruby_event_store/null'
21
+ require_relative 'ruby_event_store/transform_keys'
22
+ require_relative 'ruby_event_store/mappers/encryption_key'
23
+ require_relative 'ruby_event_store/mappers/in_memory_encryption_key_repository'
24
+ require_relative 'ruby_event_store/mappers/transformation/domain_event'
25
+ require_relative 'ruby_event_store/mappers/transformation/encryption'
26
+ require_relative 'ruby_event_store/mappers/transformation/event_class_remapper'
27
+ require_relative 'ruby_event_store/mappers/transformation/upcast'
28
+ require_relative 'ruby_event_store/mappers/transformation/stringify_metadata_keys'
29
+ require_relative 'ruby_event_store/mappers/transformation/symbolize_metadata_keys'
30
+ require_relative 'ruby_event_store/mappers/pipeline'
31
+ require_relative 'ruby_event_store/mappers/pipeline_mapper'
32
+ require_relative 'ruby_event_store/mappers/default'
33
+ require_relative 'ruby_event_store/mappers/forgotten_data'
34
+ require_relative 'ruby_event_store/mappers/encryption_mapper'
35
+ require_relative 'ruby_event_store/mappers/instrumented_mapper'
36
+ require_relative 'ruby_event_store/mappers/json_mapper'
37
+ require_relative 'ruby_event_store/mappers/null_mapper'
38
+ require_relative 'ruby_event_store/batch_enumerator'
39
+ require_relative 'ruby_event_store/correlated_commands'
40
+ require_relative 'ruby_event_store/link_by_metadata'
41
+ require_relative 'ruby_event_store/immediate_async_dispatcher'
42
+ require_relative 'ruby_event_store/composed_dispatcher'
43
+ require_relative 'ruby_event_store/version'
44
+ require_relative 'ruby_event_store/instrumented_repository'
45
+ require_relative 'ruby_event_store/instrumented_dispatcher'
@@ -131,8 +131,8 @@ module RubyEventStore
131
131
  #
132
132
  # @param to [Class, String] type of events to get list of sybscribed handlers
133
133
  # @return [Array<Object, Class>]
134
- def subscribers_for(event_type)
135
- subscriptions.all_for(event_type)
134
+ def subscribers_for(event_class)
135
+ subscriptions.all_for(event_type_resolver.call(event_class))
136
136
  end
137
137
 
138
138
  # Builder object for collecting temporary handlers (subscribers)
@@ -328,6 +328,10 @@ module RubyEventStore
328
328
 
329
329
  protected
330
330
 
331
+ def event_type_resolver
332
+ subscriptions.event_type_resolver
333
+ end
334
+
331
335
  def metadata=(value)
332
336
  @metadata.value = value
333
337
  end
@@ -5,9 +5,9 @@ module RubyEventStore
5
5
  module Transformation
6
6
  class DomainEvent
7
7
  def dump(domain_event)
8
- metadata = domain_event.metadata.to_h
8
+ metadata = domain_event.metadata.dup.to_h
9
9
  timestamp = metadata.delete(:timestamp)
10
- valid_at = metadata.delete(:valid_at)
10
+ valid_at = metadata.delete(:valid_at)
11
11
  Record.new(
12
12
  event_id: domain_event.event_id,
13
13
  metadata: metadata,
@@ -972,6 +972,8 @@ module RubyEventStore
972
972
 
973
973
  specify do
974
974
  expect(repository.read(specification.in_batches.result)).to be_kind_of(Enumerator)
975
+ expect(repository.read(specification.in_batches.as_at.result)).to be_kind_of(Enumerator)
976
+ expect(repository.read(specification.in_batches.as_of.result)).to be_kind_of(Enumerator)
975
977
  events = Array.new(10) { SRecord.new }
976
978
  repository.append_to_stream(
977
979
  events,
@@ -979,6 +981,9 @@ module RubyEventStore
979
981
  ExpectedVersion.none
980
982
  )
981
983
  expect(repository.read(specification.in_batches.result)).to be_kind_of(Enumerator)
984
+ expect(repository.read(specification.in_batches.as_at.result)).to be_kind_of(Enumerator)
985
+ expect(repository.read(specification.in_batches.as_of.result)).to be_kind_of(Enumerator)
986
+
982
987
  end
983
988
 
984
989
  specify do
@@ -1390,5 +1395,21 @@ module RubyEventStore
1390
1395
  expect(repository.read(specification.as_of.result).map(&:event_id)).to eq [e3, e2, e1]
1391
1396
  expect(repository.read(specification.as_of.backward.result).map(&:event_id)).to eq [e1, e2, e3]
1392
1397
  end
1398
+
1399
+ specify "time order is respected with batches" do
1400
+ repository.append_to_stream([
1401
+ SRecord.new(event_id: e1 = SecureRandom.uuid, timestamp: Time.new(2020,1,1), valid_at: Time.new(2020,1,9)),
1402
+ SRecord.new(event_id: e2 = SecureRandom.uuid, timestamp: Time.new(2020,1,3), valid_at: Time.new(2020,1,6)),
1403
+ SRecord.new(event_id: e3 = SecureRandom.uuid, timestamp: Time.new(2020,1,2), valid_at: Time.new(2020,1,3)),
1404
+ ],
1405
+ Stream.new("Dummy"),
1406
+ ExpectedVersion.any
1407
+ )
1408
+ expect(repository.read(specification.in_batches.result).to_a.flatten.map(&:event_id)).to eq [e1, e2, e3]
1409
+ expect(repository.read(specification.in_batches.as_at.result).to_a.flatten.map(&:event_id)).to eq [e1, e3, e2]
1410
+ expect(repository.read(specification.in_batches.as_at.backward.result).to_a.flatten.map(&:event_id)).to eq [e2, e3, e1]
1411
+ expect(repository.read(specification.in_batches.as_of.result).to_a.flatten.map(&:event_id)).to eq [e3, e2, e1]
1412
+ expect(repository.read(specification.in_batches.as_of.backward.result).to_a.flatten.map(&:event_id)).to eq [e1, e2, e3]
1413
+ end
1393
1414
  end
1394
1415
  end
@@ -121,16 +121,5 @@ RSpec.shared_examples :subscriptions do |subscriptions_class|
121
121
  subscriptions.add_thread_subscription(handler, [Test1DomainEvent])
122
122
 
123
123
  expect(subscriptions.all_for('Test1DomainEvent')).to eq([handler, handler])
124
- expect(subscriptions.all_for(Test1DomainEvent)).to eq([handler, handler])
125
- end
126
-
127
- it 'subscribes by type of event which is a class or string with custom type resolver' do
128
- subscriptions = subscriptions_class.new(event_type_resolver: ->(type) { type.to_s.reverse })
129
- handler = TestHandler.new
130
- subscriptions.add_subscription(handler, [Test1DomainEvent])
131
- subscriptions.add_thread_subscription(handler, ['Test1DomainEvent'])
132
-
133
- expect(subscriptions.all_for('Test1DomainEvent')).to eq([handler, handler])
134
- expect(subscriptions.all_for(Test1DomainEvent)).to eq([handler, handler])
135
124
  end
136
125
  end
@@ -28,10 +28,11 @@ module RubyEventStore
28
28
  end
29
29
 
30
30
  def all_for(event_type)
31
- resolved_event_type = resolve_event_type(event_type)
32
- [local, global, thread].map{|r| r.all_for(resolved_event_type)}.reduce(&:+)
31
+ [local, global, thread].map{|r| r.all_for(event_type)}.reduce(&:+)
33
32
  end
34
33
 
34
+ attr_reader :event_type_resolver
35
+
35
36
  private
36
37
  attr_reader :local, :global, :thread
37
38
 
@@ -44,7 +45,7 @@ module RubyEventStore
44
45
  end
45
46
 
46
47
  def resolve_event_type(type)
47
- @event_type_resolver.call(type)
48
+ event_type_resolver.call(type)
48
49
  end
49
50
 
50
51
  class ThreadSubscriptions
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyEventStore
4
- VERSION = "2.1.0"
4
+ VERSION = "2.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_event_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.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-01-07 00:00:00.000000000 Z
11
+ date: 2021-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -107,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: '2.5'
110
+ version: '2.6'
111
111
  required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - ">="