ruby_event_store 0.40.1 → 0.41.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.rb +2 -2
- data/lib/ruby_event_store/batch_enumerator.rb +2 -0
- data/lib/ruby_event_store/broker.rb +2 -0
- data/lib/ruby_event_store/client.rb +2 -0
- data/lib/ruby_event_store/composed_dispatcher.rb +2 -0
- data/lib/ruby_event_store/constants.rb +2 -0
- data/lib/ruby_event_store/correlated_commands.rb +6 -1
- data/lib/ruby_event_store/dispatcher.rb +2 -0
- data/lib/ruby_event_store/errors.rb +2 -0
- data/lib/ruby_event_store/event.rb +2 -0
- data/lib/ruby_event_store/expected_version.rb +2 -0
- data/lib/ruby_event_store/immediate_async_dispatcher.rb +2 -0
- data/lib/ruby_event_store/in_memory_repository.rb +2 -2
- data/lib/ruby_event_store/instrumented_dispatcher.rb +2 -0
- data/lib/ruby_event_store/instrumented_repository.rb +2 -0
- data/lib/ruby_event_store/link_by_metadata.rb +2 -0
- data/lib/ruby_event_store/mappers/default.rb +2 -0
- data/lib/ruby_event_store/mappers/encryption_key.rb +2 -0
- data/lib/ruby_event_store/mappers/encryption_mapper.rb +2 -0
- data/lib/ruby_event_store/mappers/forgotten_data.rb +2 -0
- data/lib/ruby_event_store/mappers/in_memory_encryption_key_repository.rb +2 -0
- data/lib/ruby_event_store/mappers/instrumented_mapper.rb +2 -0
- data/lib/ruby_event_store/mappers/null_mapper.rb +2 -0
- data/lib/ruby_event_store/mappers/pipeline.rb +2 -0
- data/lib/ruby_event_store/mappers/pipeline_mapper.rb +2 -0
- data/lib/ruby_event_store/mappers/protobuf.rb +2 -0
- data/lib/ruby_event_store/mappers/transformation/domain_event.rb +2 -0
- data/lib/ruby_event_store/mappers/transformation/encryption.rb +2 -0
- data/lib/ruby_event_store/mappers/transformation/event_class_remapper.rb +2 -0
- data/lib/ruby_event_store/mappers/transformation/item.rb +2 -1
- data/lib/ruby_event_store/mappers/transformation/proto_event.rb +2 -0
- data/lib/ruby_event_store/mappers/transformation/protobuf_encoder.rb +2 -0
- data/lib/ruby_event_store/mappers/transformation/protobuf_nested_struct_metadata.rb +2 -0
- data/lib/ruby_event_store/mappers/transformation/serialization.rb +2 -0
- data/lib/ruby_event_store/mappers/transformation/serialized_record.rb +2 -0
- data/lib/ruby_event_store/mappers/transformation/stringify_metadata_keys.rb +2 -0
- data/lib/ruby_event_store/mappers/transformation/symbolize_metadata_keys.rb +2 -0
- data/lib/ruby_event_store/metadata.rb +2 -0
- data/lib/ruby_event_store/projection.rb +1 -0
- data/lib/ruby_event_store/serialized_record.rb +2 -0
- data/lib/ruby_event_store/spec/event_repository_lint.rb +41 -41
- data/lib/ruby_event_store/specification.rb +2 -0
- data/lib/ruby_event_store/specification_reader.rb +2 -0
- data/lib/ruby_event_store/specification_result.rb +2 -0
- data/lib/ruby_event_store/stream.rb +2 -0
- data/lib/ruby_event_store/subscriptions.rb +2 -0
- data/lib/ruby_event_store/transform_keys.rb +22 -16
- data/lib/ruby_event_store/version.rb +3 -1
- metadata +4 -5
- data/lib/ruby_event_store/mappers.rb +0 -10
- data/lib/ruby_event_store/pub_sub.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1658bfe17f427fc225085c8617d29890cc558bd88b107bb6b63ed60df7839bea
|
4
|
+
data.tar.gz: e3d81397bdca548ffa42bd55cdb71a53c0740a096d4260ad7b687a7a7fb8c9f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5ebea6de2425bf325fbae3083dc77ed4f1d1a82aa37ef9efe98e059bd6e40237390eacaa780053399c9d431f8a87e588eec280b758b75870810c0de3a421b5b
|
7
|
+
data.tar.gz: e4b40a745027969129d82cd53bb846929ad8e2b8138873a173cb7f867db8f85a7b9dd776cbc5afbeacd5d6ef1db0d203aa29e81f04989c94b4afcdd16ffbb3ae
|
data/lib/ruby_event_store.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'ruby_event_store/dispatcher'
|
2
4
|
require 'ruby_event_store/subscriptions'
|
3
5
|
require 'ruby_event_store/broker'
|
4
|
-
require 'ruby_event_store/pub_sub'
|
5
6
|
require 'ruby_event_store/in_memory_repository'
|
6
7
|
require 'ruby_event_store/projection'
|
7
8
|
require 'ruby_event_store/errors'
|
@@ -16,7 +17,6 @@ require 'ruby_event_store/stream'
|
|
16
17
|
require 'ruby_event_store/expected_version'
|
17
18
|
require 'ruby_event_store/serialized_record'
|
18
19
|
require 'ruby_event_store/transform_keys'
|
19
|
-
require 'ruby_event_store/mappers'
|
20
20
|
require 'ruby_event_store/mappers/encryption_key'
|
21
21
|
require 'ruby_event_store/mappers/in_memory_encryption_key_repository'
|
22
22
|
require 'ruby_event_store/mappers/transformation/domain_event'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RubyEventStore
|
2
4
|
class CorrelatedCommands
|
3
5
|
|
@@ -10,7 +12,10 @@ module RubyEventStore
|
|
10
12
|
end
|
11
13
|
|
12
14
|
def call(command)
|
13
|
-
|
15
|
+
correlation_id = event_store.metadata[:correlation_id]
|
16
|
+
causation_id = event_store.metadata[:causation_id]
|
17
|
+
|
18
|
+
if correlation_id && causation_id
|
14
19
|
command.correlate_with(MiniEvent.new(
|
15
20
|
correlation_id,
|
16
21
|
causation_id,
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'forwardable'
|
2
4
|
|
3
5
|
module RubyEventStore
|
@@ -47,7 +49,6 @@ module RubyEventStore
|
|
47
49
|
SAFE_HASH_METHODS = [:[], :fetch]
|
48
50
|
delegate SAFE_HASH_METHODS => :@h
|
49
51
|
|
50
|
-
private
|
51
52
|
private_constant :SAFE_HASH_METHODS
|
52
53
|
end
|
53
54
|
end
|
@@ -50,11 +50,11 @@ module RubyEventStore
|
|
50
50
|
repository.read(scope.result).to_a
|
51
51
|
end
|
52
52
|
|
53
|
-
def read_events_forward(
|
53
|
+
def read_events_forward(_repository, stream = nil, from: nil, to: nil, count: nil)
|
54
54
|
read_events(specification, stream, from: from, to: to, count: count)
|
55
55
|
end
|
56
56
|
|
57
|
-
def read_events_backward(
|
57
|
+
def read_events_backward(_repository, stream = nil, from: nil, to: nil, count: nil)
|
58
58
|
read_events(specification.backward, stream, from: from, to: to, count: count)
|
59
59
|
end
|
60
60
|
|
@@ -63,18 +63,18 @@ module RubyEventStore
|
|
63
63
|
end
|
64
64
|
|
65
65
|
specify 'append_to_stream returns self' do
|
66
|
-
repository
|
67
|
-
append_to_stream(event = SRecord.new, stream, version_none)
|
68
|
-
append_to_stream(event = SRecord.new, stream, version_0)
|
66
|
+
repository
|
67
|
+
.append_to_stream(event = SRecord.new, stream, version_none)
|
68
|
+
.append_to_stream(event = SRecord.new, stream, version_0)
|
69
69
|
end
|
70
70
|
|
71
71
|
specify 'link_to_stream returns self' do
|
72
72
|
event0 = SRecord.new
|
73
73
|
event1 = SRecord.new
|
74
|
-
repository
|
75
|
-
append_to_stream([event0, event1], stream, version_none)
|
76
|
-
link_to_stream(event0.event_id, stream_flow, version_none)
|
77
|
-
link_to_stream(event1.event_id, stream_flow, version_0)
|
74
|
+
repository
|
75
|
+
.append_to_stream([event0, event1], stream, version_none)
|
76
|
+
.link_to_stream(event0.event_id, stream_flow, version_none)
|
77
|
+
.link_to_stream(event1.event_id, stream_flow, version_0)
|
78
78
|
end
|
79
79
|
|
80
80
|
specify 'adds an initial event to a new stream' do
|
@@ -85,9 +85,9 @@ module RubyEventStore
|
|
85
85
|
end
|
86
86
|
|
87
87
|
specify 'links an initial event to a new stream' do
|
88
|
-
repository
|
89
|
-
append_to_stream(event = SRecord.new, stream, version_none)
|
90
|
-
link_to_stream(event.event_id, stream_flow, version_none)
|
88
|
+
repository
|
89
|
+
.append_to_stream(event = SRecord.new, stream, version_none)
|
90
|
+
.link_to_stream(event.event_id, stream_flow, version_none)
|
91
91
|
|
92
92
|
expect(read_events_forward(repository, count: 1).first).to eq(event)
|
93
93
|
expect(read_events_forward(repository, stream).first).to eq(event)
|
@@ -591,9 +591,9 @@ module RubyEventStore
|
|
591
591
|
data: '{"order_id":3}',
|
592
592
|
metadata: '{"request_id":4}',
|
593
593
|
)
|
594
|
-
repository
|
595
|
-
append_to_stream(event, stream, version_any)
|
596
|
-
link_to_stream(event.event_id, stream_flow, version_any)
|
594
|
+
repository
|
595
|
+
.append_to_stream(event, stream, version_any)
|
596
|
+
.link_to_stream(event.event_id, stream_flow, version_any)
|
597
597
|
retrieved_event = read_events_forward(repository, stream_flow).first
|
598
598
|
expect(retrieved_event.metadata).to eq('{"request_id":4}')
|
599
599
|
expect(retrieved_event.data).to eq('{"order_id":3}')
|
@@ -611,9 +611,9 @@ module RubyEventStore
|
|
611
611
|
end
|
612
612
|
|
613
613
|
it 'does not have deleted streams with linked events' do
|
614
|
-
repository
|
615
|
-
append_to_stream(e1 = SRecord.new, stream, version_none)
|
616
|
-
link_to_stream(e1.event_id, stream_flow, version_none)
|
614
|
+
repository
|
615
|
+
.append_to_stream(e1 = SRecord.new, stream, version_none)
|
616
|
+
.link_to_stream(e1.event_id, stream_flow, version_none)
|
617
617
|
|
618
618
|
repository.delete_stream(stream_flow)
|
619
619
|
expect(read_events_forward(repository, stream_flow)).to be_empty
|
@@ -702,9 +702,9 @@ module RubyEventStore
|
|
702
702
|
].map { |id| SRecord.new(event_id: id) }
|
703
703
|
repository.append_to_stream(SRecord.new, stream_other, version_none)
|
704
704
|
events.each.with_index do |event, index|
|
705
|
-
repository
|
706
|
-
append_to_stream(event, stream, ExpectedVersion.new(index - 1))
|
707
|
-
link_to_stream(event.event_id, stream_flow, ExpectedVersion.new(index - 1))
|
705
|
+
repository
|
706
|
+
.append_to_stream(event, stream, ExpectedVersion.new(index - 1))
|
707
|
+
.link_to_stream(event.event_id, stream_flow, ExpectedVersion.new(index - 1))
|
708
708
|
end
|
709
709
|
repository.append_to_stream(SRecord.new, stream_other, version_0)
|
710
710
|
|
@@ -726,12 +726,12 @@ module RubyEventStore
|
|
726
726
|
it 'reads all stream events forward & backward' do
|
727
727
|
s1 = stream
|
728
728
|
s2 = stream_other
|
729
|
-
repository
|
730
|
-
append_to_stream(a = SRecord.new(event_id: '7010d298-ab69-4bb1-9251-f3466b5d1282'), s1, version_none)
|
731
|
-
append_to_stream(b = SRecord.new(event_id: '34f88aca-aaba-4ca0-9256-8017b47528c5'), s2, version_none)
|
732
|
-
append_to_stream(c = SRecord.new(event_id: '8e61c864-ceae-4684-8726-97c34eb8fc4f'), s1, version_0)
|
733
|
-
append_to_stream(d = SRecord.new(event_id: '30963ed9-6349-450b-ac9b-8ea50115b3bd'), s2, version_0)
|
734
|
-
append_to_stream(e = SRecord.new(event_id: '5bdc58b7-e8a7-4621-afd6-ccb828d72457'), s2, version_1)
|
729
|
+
repository
|
730
|
+
.append_to_stream(a = SRecord.new(event_id: '7010d298-ab69-4bb1-9251-f3466b5d1282'), s1, version_none)
|
731
|
+
.append_to_stream(b = SRecord.new(event_id: '34f88aca-aaba-4ca0-9256-8017b47528c5'), s2, version_none)
|
732
|
+
.append_to_stream(c = SRecord.new(event_id: '8e61c864-ceae-4684-8726-97c34eb8fc4f'), s1, version_0)
|
733
|
+
.append_to_stream(d = SRecord.new(event_id: '30963ed9-6349-450b-ac9b-8ea50115b3bd'), s2, version_0)
|
734
|
+
.append_to_stream(e = SRecord.new(event_id: '5bdc58b7-e8a7-4621-afd6-ccb828d72457'), s2, version_1)
|
735
735
|
|
736
736
|
expect(read_events_forward(repository, s1)).to eq [a,c]
|
737
737
|
expect(read_events_backward(repository, s1)).to eq [c,a]
|
@@ -739,17 +739,17 @@ module RubyEventStore
|
|
739
739
|
|
740
740
|
it 'reads all stream linked events forward & backward' do
|
741
741
|
s1, fs1, fs2 = stream, stream_flow, stream_other
|
742
|
-
repository
|
743
|
-
append_to_stream(a = SRecord.new(event_id: '7010d298-ab69-4bb1-9251-f3466b5d1282'), s1, version_none)
|
744
|
-
append_to_stream(b = SRecord.new(event_id: '34f88aca-aaba-4ca0-9256-8017b47528c5'), s1, version_0)
|
745
|
-
append_to_stream(c = SRecord.new(event_id: '8e61c864-ceae-4684-8726-97c34eb8fc4f'), s1, version_1)
|
746
|
-
append_to_stream(d = SRecord.new(event_id: '30963ed9-6349-450b-ac9b-8ea50115b3bd'), s1, version_2)
|
747
|
-
append_to_stream(e = SRecord.new(event_id: '5bdc58b7-e8a7-4621-afd6-ccb828d72457'), s1, version_3)
|
748
|
-
link_to_stream('7010d298-ab69-4bb1-9251-f3466b5d1282', fs1, version_none)
|
749
|
-
link_to_stream('34f88aca-aaba-4ca0-9256-8017b47528c5', fs2, version_none)
|
750
|
-
link_to_stream('8e61c864-ceae-4684-8726-97c34eb8fc4f', fs1, version_0)
|
751
|
-
link_to_stream('30963ed9-6349-450b-ac9b-8ea50115b3bd', fs2, version_0)
|
752
|
-
link_to_stream('5bdc58b7-e8a7-4621-afd6-ccb828d72457', fs2, version_1)
|
742
|
+
repository
|
743
|
+
.append_to_stream(a = SRecord.new(event_id: '7010d298-ab69-4bb1-9251-f3466b5d1282'), s1, version_none)
|
744
|
+
.append_to_stream(b = SRecord.new(event_id: '34f88aca-aaba-4ca0-9256-8017b47528c5'), s1, version_0)
|
745
|
+
.append_to_stream(c = SRecord.new(event_id: '8e61c864-ceae-4684-8726-97c34eb8fc4f'), s1, version_1)
|
746
|
+
.append_to_stream(d = SRecord.new(event_id: '30963ed9-6349-450b-ac9b-8ea50115b3bd'), s1, version_2)
|
747
|
+
.append_to_stream(e = SRecord.new(event_id: '5bdc58b7-e8a7-4621-afd6-ccb828d72457'), s1, version_3)
|
748
|
+
.link_to_stream('7010d298-ab69-4bb1-9251-f3466b5d1282', fs1, version_none)
|
749
|
+
.link_to_stream('34f88aca-aaba-4ca0-9256-8017b47528c5', fs2, version_none)
|
750
|
+
.link_to_stream('8e61c864-ceae-4684-8726-97c34eb8fc4f', fs1, version_0)
|
751
|
+
.link_to_stream('30963ed9-6349-450b-ac9b-8ea50115b3bd', fs2, version_0)
|
752
|
+
.link_to_stream('5bdc58b7-e8a7-4621-afd6-ccb828d72457', fs2, version_1)
|
753
753
|
|
754
754
|
expect(read_events_forward(repository, fs1)).to eq [a,c]
|
755
755
|
expect(read_events_backward(repository, fs1)).to eq [c,a]
|
@@ -801,9 +801,9 @@ module RubyEventStore
|
|
801
801
|
868cac42-3d19-4b39-84e8-cd32d65c2445
|
802
802
|
].map { |id| SRecord.new(event_id: id) }
|
803
803
|
events.each do |ev|
|
804
|
-
repository
|
805
|
-
append_to_stream(ev, Stream.new(SecureRandom.uuid), version_none)
|
806
|
-
link_to_stream(ev.event_id, Stream.new(SecureRandom.uuid), version_none)
|
804
|
+
repository
|
805
|
+
.append_to_stream(ev, Stream.new(SecureRandom.uuid), version_none)
|
806
|
+
.link_to_stream(ev.event_id, Stream.new(SecureRandom.uuid), version_none)
|
807
807
|
end
|
808
808
|
|
809
809
|
expect(read_events_forward(repository, count: 3)).to eq(events.first(3))
|
@@ -1,23 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RubyEventStore
|
2
4
|
class TransformKeys
|
3
|
-
|
4
|
-
|
5
|
-
|
5
|
+
class << self
|
6
|
+
def stringify(data)
|
7
|
+
transform(data) {|k| k.to_s}
|
8
|
+
end
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
+
def symbolize(data)
|
11
|
+
transform(data) {|k| k.to_sym}
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
10
15
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
def transform(data, &block)
|
17
|
+
data.each_with_object({}) do |(k, v), h|
|
18
|
+
h[yield(k)] =
|
19
|
+
case v
|
20
|
+
when Hash
|
21
|
+
transform(v, &block)
|
22
|
+
when Array
|
23
|
+
v.map{|i| Hash === i ? transform(i, &block) : i}
|
24
|
+
else
|
25
|
+
v
|
26
|
+
end
|
21
27
|
end
|
22
28
|
end
|
23
29
|
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: 0.
|
4
|
+
version: 0.41.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arkency
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -51,7 +51,6 @@ files:
|
|
51
51
|
- lib/ruby_event_store/instrumented_dispatcher.rb
|
52
52
|
- lib/ruby_event_store/instrumented_repository.rb
|
53
53
|
- lib/ruby_event_store/link_by_metadata.rb
|
54
|
-
- lib/ruby_event_store/mappers.rb
|
55
54
|
- lib/ruby_event_store/mappers/default.rb
|
56
55
|
- lib/ruby_event_store/mappers/encryption_key.rb
|
57
56
|
- lib/ruby_event_store/mappers/encryption_mapper.rb
|
@@ -75,7 +74,6 @@ files:
|
|
75
74
|
- lib/ruby_event_store/mappers/transformation/symbolize_metadata_keys.rb
|
76
75
|
- lib/ruby_event_store/metadata.rb
|
77
76
|
- lib/ruby_event_store/projection.rb
|
78
|
-
- lib/ruby_event_store/pub_sub.rb
|
79
77
|
- lib/ruby_event_store/serialized_record.rb
|
80
78
|
- lib/ruby_event_store/spec/broker_lint.rb
|
81
79
|
- lib/ruby_event_store/spec/dispatcher_lint.rb
|
@@ -115,7 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
113
|
- !ruby/object:Gem::Version
|
116
114
|
version: '0'
|
117
115
|
requirements: []
|
118
|
-
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 2.7.6.2
|
119
118
|
signing_key:
|
120
119
|
specification_version: 4
|
121
120
|
summary: Event Store in Ruby
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module RubyEventStore
|
2
|
-
module Mappers
|
3
|
-
def self.const_missing(const_name)
|
4
|
-
super unless const_name.equal?(:MissingEncryptionKey)
|
5
|
-
warn "`RubyEventStore::Mappers::MissingEncryptionKey` has been deprecated. Use `RubyEventStore::Mappers::Transformation::Encryption::MissingEncryptionKey` instead."
|
6
|
-
|
7
|
-
Transformation::Encryption::MissingEncryptionKey
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module RubyEventStore
|
2
|
-
module PubSub
|
3
|
-
def self.const_missing(const_name)
|
4
|
-
if const_name.equal?(:Subscriptions)
|
5
|
-
warn "`RubyEventStore::PubSub::Subscriptions` has been deprecated. Use `RubyEventStore::Subscriptions` instead."
|
6
|
-
|
7
|
-
Subscriptions
|
8
|
-
elsif const_name.equal?(:Broker)
|
9
|
-
warn "`RubyEventStore::PubSub::Broker` has been deprecated. Use `RubyEventStore::Broker` instead."
|
10
|
-
|
11
|
-
Broker
|
12
|
-
elsif const_name.equal?(:Dispatcher)
|
13
|
-
warn "`RubyEventStore::PubSub::Dispatcher` has been deprecated. Use `RubyEventStore::Dispatcher` instead."
|
14
|
-
|
15
|
-
Dispatcher
|
16
|
-
else
|
17
|
-
super
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|