ruby_event_store 0.43.0 → 0.44.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby_event_store/broker.rb +1 -1
- data/lib/ruby_event_store/event.rb +9 -14
- data/lib/ruby_event_store/link_by_metadata.rb +4 -4
- data/lib/ruby_event_store/mappers/protobuf.rb +1 -1
- data/lib/ruby_event_store/mappers/transformation/domain_event.rb +1 -1
- data/lib/ruby_event_store/projection.rb +5 -4
- data/lib/ruby_event_store/spec/broker_lint.rb +1 -1
- data/lib/ruby_event_store/spec/event_lint.rb +4 -4
- data/lib/ruby_event_store/spec/mapper_lint.rb +1 -1
- data/lib/ruby_event_store/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 368744aa127e8d45d1e6237561ffb22279452f5e71212e1bda86988ee2726c3a
|
4
|
+
data.tar.gz: 7dfbd1a66c649a6ecc90f08432047ff93aa7376eaec66ab774a5a347d574135a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88167b0f2ac9b3e7148b3772b39e1193eaed384af89c12761790b1a43d34d66677c1d91dba6926fe0d5d773dd446e3a0b8e6bbe0642dffbb1b7d081435400a93
|
7
|
+
data.tar.gz: 4eb32bd4ffe7abc50611b0dcb24d778f423d68322b7e9a0dee52680a3dddcc6bfeae1a70a4e744dce071357e9d3ebd85648afb4ba70dfe8eb96c0cc45d34b73e
|
@@ -8,7 +8,7 @@ module RubyEventStore
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def call(event, serialized_event)
|
11
|
-
subscribers = subscriptions.all_for(event.
|
11
|
+
subscribers = subscriptions.all_for(event.event_type)
|
12
12
|
subscribers.each do |subscriber|
|
13
13
|
dispatcher.call(subscriber, event, serialized_event)
|
14
14
|
end
|
@@ -30,22 +30,17 @@ module RubyEventStore
|
|
30
30
|
|
31
31
|
# Type of event. Used when matching with subscribed handlers.
|
32
32
|
# @return [String]
|
33
|
-
def
|
33
|
+
def event_type
|
34
34
|
self.class.name
|
35
35
|
end
|
36
36
|
|
37
|
-
#
|
38
|
-
#
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
event_id: event_id,
|
45
|
-
metadata: metadata.to_h,
|
46
|
-
data: data,
|
47
|
-
type: type,
|
48
|
-
}
|
37
|
+
# Type of event. Used when matching with subscribed handlers.
|
38
|
+
# @return [String]
|
39
|
+
def type
|
40
|
+
warn <<~EOW
|
41
|
+
`type` has been deprecated. Use `event_type` instead.
|
42
|
+
EOW
|
43
|
+
event_type
|
49
44
|
end
|
50
45
|
|
51
46
|
# Timestamp from metadata
|
@@ -140,4 +135,4 @@ module RubyEventStore
|
|
140
135
|
|
141
136
|
alias_method :eql?, :==
|
142
137
|
end
|
143
|
-
end
|
138
|
+
end
|
@@ -13,7 +13,7 @@ module RubyEventStore
|
|
13
13
|
return unless event.metadata.has_key?(@key)
|
14
14
|
|
15
15
|
@event_store.link(
|
16
|
-
[event.
|
16
|
+
[event.event_id],
|
17
17
|
stream_name: "#{@prefix}#{event.metadata.fetch(@key)}"
|
18
18
|
)
|
19
19
|
end
|
@@ -48,10 +48,10 @@ module RubyEventStore
|
|
48
48
|
|
49
49
|
def call(event)
|
50
50
|
@event_store.link(
|
51
|
-
[event.
|
52
|
-
stream_name: "#{@prefix}#{event.
|
51
|
+
[event.event_id],
|
52
|
+
stream_name: "#{@prefix}#{event.event_type}"
|
53
53
|
)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
end
|
57
|
+
end
|
@@ -15,8 +15,8 @@ module RubyEventStore
|
|
15
15
|
|
16
16
|
def initialize(streams: [])
|
17
17
|
@streams = streams
|
18
|
-
@handlers =
|
19
|
-
@init = -> {
|
18
|
+
@handlers = {}
|
19
|
+
@init = -> { {} }
|
20
20
|
end
|
21
21
|
|
22
22
|
attr_reader :streams, :handlers
|
@@ -43,7 +43,7 @@ module RubyEventStore
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def call(event)
|
46
|
-
handlers.fetch(event.
|
46
|
+
handlers.fetch(event.event_type).(current_state, event)
|
47
47
|
end
|
48
48
|
|
49
49
|
def handled_events
|
@@ -83,6 +83,7 @@ module RubyEventStore
|
|
83
83
|
|
84
84
|
def read_scope(event_store, stream, count, start)
|
85
85
|
scope = event_store.read.in_batches(count)
|
86
|
+
scope = scope.of_type(handled_events)
|
86
87
|
scope = scope.stream(stream) if stream
|
87
88
|
scope = scope.from(start) if start
|
88
89
|
scope
|
@@ -93,7 +94,7 @@ module RubyEventStore
|
|
93
94
|
end
|
94
95
|
|
95
96
|
def transition(state, event)
|
96
|
-
handlers
|
97
|
+
handlers.fetch(event.event_type).call(state, event)
|
97
98
|
state
|
98
99
|
end
|
99
100
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
RSpec.shared_examples :broker do |broker_klass|
|
2
|
-
let(:event) { instance_double(::RubyEventStore::Event,
|
2
|
+
let(:event) { instance_double(::RubyEventStore::Event, event_type: 'EventType') }
|
3
3
|
let(:serialized_event) { instance_double(::RubyEventStore::SerializedRecord) }
|
4
4
|
let(:handler) { HandlerClass.new }
|
5
5
|
let(:subscriptions) { ::RubyEventStore::Subscriptions.new }
|
@@ -29,11 +29,11 @@ RSpec.shared_examples :event do |event_class|
|
|
29
29
|
expect(event.event_id).to eq '1234567890'
|
30
30
|
end
|
31
31
|
|
32
|
-
it 'provides type as string' do
|
32
|
+
it 'provides event type as string' do
|
33
33
|
event = event_class.new
|
34
|
-
expect(event.
|
35
|
-
expect(event.
|
36
|
-
expect(event.
|
34
|
+
expect(event.event_type).to be_an_instance_of(String)
|
35
|
+
expect(event.event_type).not_to eq ''
|
36
|
+
expect(event.event_type).not_to eq nil
|
37
37
|
end
|
38
38
|
|
39
39
|
it "provides data" do
|
@@ -5,7 +5,7 @@ module RubyEventStore
|
|
5
5
|
|
6
6
|
expect(record).to be_kind_of(SerializedRecord)
|
7
7
|
expect(record.event_id).to eq(domain_event.event_id)
|
8
|
-
expect(record.event_type).to eq(domain_event.
|
8
|
+
expect(record.event_type).to eq(domain_event.event_type)
|
9
9
|
end
|
10
10
|
|
11
11
|
specify "serialize and deserialize gives equal event" do
|
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: 0.
|
4
|
+
version: 0.44.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arkency
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|