ruby_event_store 2.0.3 → 2.1.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: 285893bc28288225780ac559aa8a3ef11e1b5a769870f5821161273b7087b3bb
4
- data.tar.gz: 43112f7f7bc9e0e1cbc38f0a5d3e574575b91e94f208803e533ffe0f4b782b04
3
+ metadata.gz: 88203a9b943002241df25fa83c6f067e7944810e66d713eeb11e8cebf13271e2
4
+ data.tar.gz: 1b032e898517d787a2e6d0cb6b15775792591abc094e68d2483590f916e69c9e
5
5
  SHA512:
6
- metadata.gz: 376292ff1199abb79bc64adfea0335b8c9b898963313a9d136b943eea666319cefeeceb8891c305d7fe51e1985fe151a27713ae14dc33038858f6c4a34bb024d
7
- data.tar.gz: 62f53d5723681398e5ad972b2807248912e7e0b610b3bc8790bba5c9a107a1f8da132e279b79ac246dff80efac8b3a7c895f2691496a4bf156d8720bc36727ef
6
+ metadata.gz: 780c9e0f6064311d45be29c0553c47e65e679a3967b91e6caca48a55ef9c34a06070e421b1413c1a35634c6e45c1452204ac29fae2aa706fe7a0e46d1dd99f40
7
+ data.tar.gz: 66b7a11ce2d3b58a5f9c2690a7f7f998fc9130c302343923cdd5a57a63d6a398ea258cced2d1b3161e07d9fb081d04bd7c4f305d6576cae59bd6e50f50ba6a92
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
1
  # RubyEventStore
2
2
 
3
- A Ruby implementation of an EventStore. It is an integral part of `rails_event_store` gem.
3
+ Ruby implementation of an event store. Ships with in-memory event repository, generic instrumentation and dispatches events synchronously.
4
+
5
+ Find out more at [https://railseventstore.org](https://railseventstore.org/)
@@ -13,7 +13,7 @@ module RubyEventStore
13
13
 
14
14
 
15
15
  @repository = repository
16
- @mapper = Mappers::DeprecatedWrapper.new(mapper)
16
+ @mapper = mapper
17
17
  @subscriptions = subscriptions
18
18
  @broker = Broker.new(subscriptions: subscriptions, dispatcher: dispatcher)
19
19
  @clock = clock
@@ -64,7 +64,7 @@ module RubyEventStore
64
64
  # @param expected_version (see #publish)
65
65
  # @return [self]
66
66
  def link(event_ids, stream_name:, expected_version: :any)
67
- repository.link_to_stream(event_ids, Stream.new(stream_name), ExpectedVersion.new(expected_version))
67
+ repository.link_to_stream(Array(event_ids), Stream.new(stream_name), ExpectedVersion.new(expected_version))
68
68
  self
69
69
  end
70
70
 
@@ -132,7 +132,7 @@ module RubyEventStore
132
132
  # @param to [Class, String] type of events to get list of sybscribed handlers
133
133
  # @return [Array<Object, Class>]
134
134
  def subscribers_for(event_type)
135
- subscriptions.all_for(event_type.to_s)
135
+ subscriptions.all_for(event_type)
136
136
  end
137
137
 
138
138
  # Builder object for collecting temporary handlers (subscribers)
@@ -12,7 +12,7 @@ module RubyEventStore
12
12
  end
13
13
 
14
14
  def append_to_stream(records, stream, expected_version)
15
- serialized_records = Array(records).map{ |record| record.serialize(serializer) }
15
+ serialized_records = records.map { |record| record.serialize(serializer) }
16
16
 
17
17
  with_synchronize(expected_version, stream) do |resolved_version|
18
18
  raise WrongExpectedEventVersion unless last_stream_version(stream).equal?(resolved_version)
@@ -27,7 +27,7 @@ module RubyEventStore
27
27
  end
28
28
 
29
29
  def link_to_stream(event_ids, stream, expected_version)
30
- serialized_records = Array(event_ids).map { |id| read_event(id) }
30
+ serialized_records = event_ids.map { |id| read_event(id) }
31
31
 
32
32
  with_synchronize(expected_version, stream) do |resolved_version|
33
33
  raise WrongExpectedEventVersion unless last_stream_version(stream).equal?(resolved_version)
@@ -60,7 +60,7 @@ module RubyEventStore
60
60
  serialized_records
61
61
  .drop(offset)
62
62
  .take(limit)
63
- .map{|serialized_record| serialized_record.deserialize(serializer) }
63
+ .map { |serialized_record| serialized_record.deserialize(serializer) }
64
64
  end
65
65
  BatchEnumerator.new(spec.batch_size, serialized_records.size, batch_reader).each
66
66
  elsif spec.first?
@@ -7,9 +7,9 @@ module RubyEventStore
7
7
  @instrumentation = instrumentation
8
8
  end
9
9
 
10
- def append_to_stream(events, stream, expected_version)
11
- instrumentation.instrument("append_to_stream.repository.rails_event_store", events: events, stream: stream) do
12
- repository.append_to_stream(events, stream, expected_version)
10
+ def append_to_stream(records, stream, expected_version)
11
+ instrumentation.instrument("append_to_stream.repository.rails_event_store", events: records, stream: stream) do
12
+ repository.append_to_stream(records, stream, expected_version)
13
13
  end
14
14
  end
15
15
 
@@ -1,36 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'yaml'
4
-
5
3
  module RubyEventStore
6
4
  module Mappers
7
5
  class Default < PipelineMapper
8
- UNSET = Object.new.freeze
9
-
10
- attr_reader :serializer
11
-
12
- def initialize(serializer: UNSET, events_class_remapping: {})
13
- case serializer
14
- when UNSET
15
- @serializer = YAML
16
- else
17
- warn <<~EOW
18
- Passing serializer: to #{self.class} has been deprecated.
19
-
20
- Pass it directly to the repository and the scheduler. For example:
21
-
22
- Rails.configuration.event_store = RailsEventStore::Client.new(
23
- mapper: RubyEventStore::Mappers::Default.new,
24
- repository: RailsEventStoreActiveRecord::EventRepository.new(serializer: #{serializer}),
25
- dispatcher: RubyEventStore::ComposedDispatcher.new(
26
- RailsEventStore::AfterCommitAsyncDispatcher.new(scheduler: RailsEventStore::ActiveJobScheduler.new(serializer: #{serializer}),
27
- RubyEventStore::Dispatcher.new
28
- )
29
- )
30
- EOW
31
- @serializer = serializer
32
- end
33
-
6
+ def initialize(events_class_remapping: {})
34
7
  super(Pipeline.new(
35
8
  Transformation::EventClassRemapper.new(events_class_remapping),
36
9
  Transformation::SymbolizeMetadataKeys.new,
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'yaml'
4
+
3
5
  module RubyEventStore
4
6
  module Mappers
5
7
  class EncryptionMapper < PipelineMapper
@@ -20,10 +20,6 @@ module RubyEventStore
20
20
  end
21
21
  end
22
22
 
23
- def serializer
24
- mapper.serializer
25
- end
26
-
27
23
  private
28
24
 
29
25
  attr_reader :instrumentation, :mapper
@@ -2,12 +2,14 @@
2
2
 
3
3
  module RubyEventStore
4
4
  module Mappers
5
- class JSONMapper < PipelineMapper
5
+ class JSONMapper < Default
6
6
  def initialize(events_class_remapping: {})
7
- super(Pipeline.new(
8
- Transformation::EventClassRemapper.new(events_class_remapping),
9
- Transformation::SymbolizeMetadataKeys.new,
10
- ))
7
+ warn <<~EOW
8
+ Please replace RubyEventStore::Mappers::JSONMapper with RubyEventStore::Mappers::Default
9
+
10
+ They're now identical and the former will be removed in next major release.
11
+ EOW
12
+ super
11
13
  end
12
14
  end
13
15
  end
@@ -3,13 +3,10 @@
3
3
  module RubyEventStore
4
4
  module Mappers
5
5
  class Pipeline
6
- UNSET = Object.new.freeze
7
-
8
- def initialize(*transformations_, transformations: UNSET, to_domain_event: Transformation::DomainEvent.new)
6
+ def initialize(*transformations, to_domain_event: Transformation::DomainEvent.new)
9
7
  @transformations = [
10
8
  to_domain_event,
11
- deprecated_transformations(transformations),
12
- transformations_,
9
+ transformations,
13
10
  ].flatten.freeze
14
11
  end
15
12
 
@@ -26,27 +23,6 @@ module RubyEventStore
26
23
  end
27
24
 
28
25
  attr_reader :transformations
29
-
30
- private
31
-
32
- def deprecated_transformations(transformations)
33
- case transformations
34
- when UNSET
35
- []
36
- else
37
- warn <<~EOW
38
- Passing transformations via keyword parameter is deprecated.
39
- Please use positional arguments from now on.
40
-
41
- Was:
42
- RubyEventStore::Mappers::Pipeline.new(transformations: transformations)
43
-
44
- Is now:
45
- RubyEventStore::Mappers::Pipeline.new(*transformations)
46
- EOW
47
- transformations
48
- end
49
- end
50
26
  end
51
27
  end
52
28
  end
@@ -15,10 +15,6 @@ module RubyEventStore
15
15
  pipeline.load(record)
16
16
  end
17
17
 
18
- def serializer
19
- NULL
20
- end
21
-
22
18
  private
23
19
  attr_reader :pipeline
24
20
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyEventStore
4
+ module Mappers
5
+ module Transformation
6
+ class Upcast
7
+ class RecordUpcaster
8
+ def initialize(upcast_map)
9
+ @upcast_map = upcast_map
10
+ end
11
+
12
+ def call(record)
13
+ identity = lambda { |r| r }
14
+ new_record = @upcast_map.fetch(record.event_type, identity)[record]
15
+ if new_record.equal?(record)
16
+ record
17
+ else
18
+ call(new_record)
19
+ end
20
+ end
21
+ end
22
+
23
+ def initialize(upcast_map)
24
+ @record_upcaster = RecordUpcaster.new(upcast_map)
25
+ end
26
+
27
+ def dump(record)
28
+ record
29
+ end
30
+
31
+ def load(record)
32
+ @record_upcaster.call(record)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -105,8 +105,8 @@ module RubyEventStore
105
105
 
106
106
  specify 'append_to_stream returns self' do
107
107
  repository
108
- .append_to_stream(event = SRecord.new, stream, version_none)
109
- .append_to_stream(event = SRecord.new, stream, version_0)
108
+ .append_to_stream([event = SRecord.new], stream, version_none)
109
+ .append_to_stream([event = SRecord.new], stream, version_0)
110
110
  end
111
111
 
112
112
  specify 'link_to_stream returns self' do
@@ -114,12 +114,12 @@ module RubyEventStore
114
114
  event1 = SRecord.new
115
115
  repository
116
116
  .append_to_stream([event0, event1], stream, version_none)
117
- .link_to_stream(event0.event_id, stream_flow, version_none)
118
- .link_to_stream(event1.event_id, stream_flow, version_0)
117
+ .link_to_stream([event0.event_id], stream_flow, version_none)
118
+ .link_to_stream([event1.event_id], stream_flow, version_0)
119
119
  end
120
120
 
121
121
  specify 'adds an initial event to a new stream' do
122
- repository.append_to_stream(event = SRecord.new, stream, version_none)
122
+ repository.append_to_stream([event = SRecord.new], stream, version_none)
123
123
  expect(read_events_forward(repository).first).to eq(event)
124
124
  expect(read_events_forward(repository, stream).first).to eq(event)
125
125
  expect(read_events_forward(repository, stream_other)).to be_empty
@@ -127,8 +127,8 @@ module RubyEventStore
127
127
 
128
128
  specify 'links an initial event to a new stream' do
129
129
  repository
130
- .append_to_stream(event = SRecord.new, stream, version_none)
131
- .link_to_stream(event.event_id, stream_flow, version_none)
130
+ .append_to_stream([event = SRecord.new], stream, version_none)
131
+ .link_to_stream([event.event_id], stream_flow, version_none)
132
132
 
133
133
  expect(read_events_forward(repository, count: 1).first).to eq(event)
134
134
  expect(read_events_forward(repository, stream).first).to eq(event)
@@ -494,7 +494,7 @@ module RubyEventStore
494
494
  begin
495
495
  100.times do |j|
496
496
  eid = "0000000#{i}-#{sprintf("%04d", j)}-0000-0000-000000000000"
497
- repository.link_to_stream(eid, stream_flow, version_any)
497
+ repository.link_to_stream([eid], stream_flow, version_any)
498
498
  end
499
499
  rescue WrongExpectedEventVersion
500
500
  fail_occurred = true
@@ -581,7 +581,7 @@ module RubyEventStore
581
581
  100.times do |j|
582
582
  begin
583
583
  eid = "0000000#{i}-#{sprintf("%04d", j)}-0000-0000-000000000000"
584
- repository.link_to_stream(eid, stream, version_auto)
584
+ repository.link_to_stream([eid], stream, version_auto)
585
585
  sleep(rand(concurrency_level) / 1000.0)
586
586
  rescue WrongExpectedEventVersion, *helper.rescuable_concurrency_test_errors
587
587
  fail_occurred +=1
@@ -607,7 +607,7 @@ module RubyEventStore
607
607
 
608
608
  it 'appended event is stored in given stream' do
609
609
  expected_event = SRecord.new
610
- repository.append_to_stream(expected_event, stream, version_any)
610
+ repository.append_to_stream([expected_event], stream, version_any)
611
611
  expect(read_events_forward(repository, count: 1).first).to eq(expected_event)
612
612
  expect(read_events_forward(repository, stream).first).to eq(expected_event)
613
613
  expect(read_events_forward(repository, stream_other)).to be_empty
@@ -615,14 +615,14 @@ module RubyEventStore
615
615
 
616
616
  it 'data attributes are retrieved' do
617
617
  event = SRecord.new(data: { "order_id" => 3 })
618
- repository.append_to_stream(event, stream, version_any)
618
+ repository.append_to_stream([event], stream, version_any)
619
619
  retrieved_event = read_events_forward(repository, count: 1).first
620
620
  expect(retrieved_event.data).to eq({ "order_id" => 3 })
621
621
  end
622
622
 
623
623
  it 'metadata attributes are retrieved' do
624
624
  event = SRecord.new(metadata: { "request_id" => 3 })
625
- repository.append_to_stream(event, stream, version_any)
625
+ repository.append_to_stream([event], stream, version_any)
626
626
  retrieved_event = read_events_forward(repository, count: 1).first
627
627
  expect(retrieved_event.metadata).to eq({ "request_id" => 3 })
628
628
  end
@@ -633,8 +633,8 @@ module RubyEventStore
633
633
  metadata: { "request_id" => 4},
634
634
  )
635
635
  repository
636
- .append_to_stream(event, stream, version_any)
637
- .link_to_stream(event.event_id, stream_flow, version_any)
636
+ .append_to_stream([event], stream, version_any)
637
+ .link_to_stream([event.event_id], stream_flow, version_any)
638
638
  retrieved_event = read_events_forward(repository, stream_flow).first
639
639
  expect(retrieved_event.metadata).to eq({ "request_id" => 4 })
640
640
  expect(retrieved_event.data).to eq({ "order_id" => 3 })
@@ -642,8 +642,8 @@ module RubyEventStore
642
642
  end
643
643
 
644
644
  it 'does not have deleted streams' do
645
- repository.append_to_stream(e1 = SRecord.new, stream, version_none)
646
- repository.append_to_stream(e2 = SRecord.new, stream_other, version_none)
645
+ repository.append_to_stream([e1 = SRecord.new], stream, version_none)
646
+ repository.append_to_stream([e2 = SRecord.new], stream_other, version_none)
647
647
 
648
648
  repository.delete_stream(stream)
649
649
  expect(read_events_forward(repository, stream)).to be_empty
@@ -653,8 +653,8 @@ module RubyEventStore
653
653
 
654
654
  it 'does not have deleted streams with linked events' do
655
655
  repository
656
- .append_to_stream(e1 = SRecord.new, stream, version_none)
657
- .link_to_stream(e1.event_id, stream_flow, version_none)
656
+ .append_to_stream([e1 = SRecord.new], stream, version_none)
657
+ .link_to_stream([e1.event_id], stream_flow, version_none)
658
658
 
659
659
  repository.delete_stream(stream_flow)
660
660
  expect(read_events_forward(repository, stream_flow)).to be_empty
@@ -663,7 +663,7 @@ module RubyEventStore
663
663
 
664
664
  it 'has or has not domain event' do
665
665
  just_an_id = 'd5c134c2-db65-4e87-b6ea-d196f8f1a292'
666
- repository.append_to_stream(SRecord.new(event_id: just_an_id), stream, version_none)
666
+ repository.append_to_stream([SRecord.new(event_id: just_an_id)], stream, version_none)
667
667
 
668
668
  expect(repository.has_event?(just_an_id)).to be_truthy
669
669
  expect(repository.has_event?(just_an_id.clone)).to be_truthy
@@ -675,8 +675,8 @@ module RubyEventStore
675
675
  end
676
676
 
677
677
  it 'knows last event in stream' do
678
- repository.append_to_stream(a =SRecord.new(event_id: '00000000-0000-0000-0000-000000000001'), stream, version_none)
679
- repository.append_to_stream(b = SRecord.new(event_id: '00000000-0000-0000-0000-000000000002'), stream, version_0)
678
+ repository.append_to_stream([a =SRecord.new(event_id: '00000000-0000-0000-0000-000000000001')], stream, version_none)
679
+ repository.append_to_stream([b = SRecord.new(event_id: '00000000-0000-0000-0000-000000000002')], stream, version_0)
680
680
 
681
681
  expect(repository.last_stream_event(stream)).to eq(b)
682
682
  expect(repository.last_stream_event(stream_other)).to be_nil
@@ -706,11 +706,11 @@ module RubyEventStore
706
706
  ab60114c-011d-4d58-ab31-7ba65d99975e
707
707
  868cac42-3d19-4b39-84e8-cd32d65c2445
708
708
  ].map { |id| SRecord.new(event_id: id) }
709
- repository.append_to_stream(SRecord.new, stream_other, version_none)
709
+ repository.append_to_stream([SRecord.new], stream_other, version_none)
710
710
  events.each.with_index do |event, index|
711
- repository.append_to_stream(event, stream, ExpectedVersion.new(index - 1))
711
+ repository.append_to_stream([event], stream, ExpectedVersion.new(index - 1))
712
712
  end
713
- repository.append_to_stream(SRecord.new, stream_other, version_0)
713
+ repository.append_to_stream([SRecord.new], stream_other, version_0)
714
714
 
715
715
  expect(read_events_forward(repository, stream, count: 3)).to eq(events.first(3))
716
716
  expect(read_events_forward(repository, stream, count: 100)).to eq(events)
@@ -741,13 +741,13 @@ module RubyEventStore
741
741
  ab60114c-011d-4d58-ab31-7ba65d99975e
742
742
  868cac42-3d19-4b39-84e8-cd32d65c2445
743
743
  ].map { |id| SRecord.new(event_id: id) }
744
- repository.append_to_stream(SRecord.new, stream_other, version_none)
744
+ repository.append_to_stream([SRecord.new], stream_other, version_none)
745
745
  events.each.with_index do |event, index|
746
746
  repository
747
- .append_to_stream(event, stream, ExpectedVersion.new(index - 1))
748
- .link_to_stream(event.event_id, stream_flow, ExpectedVersion.new(index - 1))
747
+ .append_to_stream([event], stream, ExpectedVersion.new(index - 1))
748
+ .link_to_stream([event.event_id], stream_flow, ExpectedVersion.new(index - 1))
749
749
  end
750
- repository.append_to_stream(SRecord.new, stream_other, version_0)
750
+ repository.append_to_stream([SRecord.new], stream_other, version_0)
751
751
 
752
752
  expect(read_events_forward(repository, stream_flow, count: 3)).to eq(events.first(3))
753
753
  expect(read_events_forward(repository, stream_flow, count: 100)).to eq(events)
@@ -768,11 +768,11 @@ module RubyEventStore
768
768
  s1 = stream
769
769
  s2 = stream_other
770
770
  repository
771
- .append_to_stream(a = SRecord.new(event_id: '7010d298-ab69-4bb1-9251-f3466b5d1282'), s1, version_none)
772
- .append_to_stream(b = SRecord.new(event_id: '34f88aca-aaba-4ca0-9256-8017b47528c5'), s2, version_none)
773
- .append_to_stream(c = SRecord.new(event_id: '8e61c864-ceae-4684-8726-97c34eb8fc4f'), s1, version_0)
774
- .append_to_stream(d = SRecord.new(event_id: '30963ed9-6349-450b-ac9b-8ea50115b3bd'), s2, version_0)
775
- .append_to_stream(e = SRecord.new(event_id: '5bdc58b7-e8a7-4621-afd6-ccb828d72457'), s2, version_1)
771
+ .append_to_stream([a = SRecord.new(event_id: '7010d298-ab69-4bb1-9251-f3466b5d1282')], s1, version_none)
772
+ .append_to_stream([b = SRecord.new(event_id: '34f88aca-aaba-4ca0-9256-8017b47528c5')], s2, version_none)
773
+ .append_to_stream([c = SRecord.new(event_id: '8e61c864-ceae-4684-8726-97c34eb8fc4f')], s1, version_0)
774
+ .append_to_stream([d = SRecord.new(event_id: '30963ed9-6349-450b-ac9b-8ea50115b3bd')], s2, version_0)
775
+ .append_to_stream([e = SRecord.new(event_id: '5bdc58b7-e8a7-4621-afd6-ccb828d72457')], s2, version_1)
776
776
 
777
777
  expect(read_events_forward(repository, s1)).to eq [a,c]
778
778
  expect(read_events_backward(repository, s1)).to eq [c,a]
@@ -781,16 +781,16 @@ module RubyEventStore
781
781
  it 'reads all stream linked events forward & backward' do
782
782
  s1, fs1, fs2 = stream, stream_flow, stream_other
783
783
  repository
784
- .append_to_stream(a = SRecord.new(event_id: '7010d298-ab69-4bb1-9251-f3466b5d1282'), s1, version_none)
785
- .append_to_stream(b = SRecord.new(event_id: '34f88aca-aaba-4ca0-9256-8017b47528c5'), s1, version_0)
786
- .append_to_stream(c = SRecord.new(event_id: '8e61c864-ceae-4684-8726-97c34eb8fc4f'), s1, version_1)
787
- .append_to_stream(d = SRecord.new(event_id: '30963ed9-6349-450b-ac9b-8ea50115b3bd'), s1, version_2)
788
- .append_to_stream(e = SRecord.new(event_id: '5bdc58b7-e8a7-4621-afd6-ccb828d72457'), s1, version_3)
789
- .link_to_stream('7010d298-ab69-4bb1-9251-f3466b5d1282', fs1, version_none)
790
- .link_to_stream('34f88aca-aaba-4ca0-9256-8017b47528c5', fs2, version_none)
791
- .link_to_stream('8e61c864-ceae-4684-8726-97c34eb8fc4f', fs1, version_0)
792
- .link_to_stream('30963ed9-6349-450b-ac9b-8ea50115b3bd', fs2, version_0)
793
- .link_to_stream('5bdc58b7-e8a7-4621-afd6-ccb828d72457', fs2, version_1)
784
+ .append_to_stream([a = SRecord.new(event_id: '7010d298-ab69-4bb1-9251-f3466b5d1282')], s1, version_none)
785
+ .append_to_stream([b = SRecord.new(event_id: '34f88aca-aaba-4ca0-9256-8017b47528c5')], s1, version_0)
786
+ .append_to_stream([c = SRecord.new(event_id: '8e61c864-ceae-4684-8726-97c34eb8fc4f')], s1, version_1)
787
+ .append_to_stream([d = SRecord.new(event_id: '30963ed9-6349-450b-ac9b-8ea50115b3bd')], s1, version_2)
788
+ .append_to_stream([e = SRecord.new(event_id: '5bdc58b7-e8a7-4621-afd6-ccb828d72457')], s1, version_3)
789
+ .link_to_stream(['7010d298-ab69-4bb1-9251-f3466b5d1282'], fs1, version_none)
790
+ .link_to_stream(['34f88aca-aaba-4ca0-9256-8017b47528c5'], fs2, version_none)
791
+ .link_to_stream(['8e61c864-ceae-4684-8726-97c34eb8fc4f'], fs1, version_0)
792
+ .link_to_stream(['30963ed9-6349-450b-ac9b-8ea50115b3bd'], fs2, version_0)
793
+ .link_to_stream(['5bdc58b7-e8a7-4621-afd6-ccb828d72457'], fs2, version_1)
794
794
 
795
795
  expect(read_events_forward(repository, fs1)).to eq [a,c]
796
796
  expect(read_events_backward(repository, fs1)).to eq [c,a]
@@ -810,7 +810,7 @@ module RubyEventStore
810
810
  868cac42-3d19-4b39-84e8-cd32d65c2445
811
811
  ].map { |id| SRecord.new(event_id: id) }
812
812
  events.each do |ev|
813
- repository.append_to_stream(ev, Stream.new(SecureRandom.uuid), version_none)
813
+ repository.append_to_stream([ev], Stream.new(SecureRandom.uuid), version_none)
814
814
  end
815
815
 
816
816
  expect(read_events_forward(repository, count: 3)).to eq(events.first(3))
@@ -843,8 +843,8 @@ module RubyEventStore
843
843
  ].map { |id| SRecord.new(event_id: id) }
844
844
  events.each do |ev|
845
845
  repository
846
- .append_to_stream(ev, Stream.new(SecureRandom.uuid), version_none)
847
- .link_to_stream(ev.event_id, Stream.new(SecureRandom.uuid), version_none)
846
+ .append_to_stream([ev], Stream.new(SecureRandom.uuid), version_none)
847
+ .link_to_stream([ev.event_id], Stream.new(SecureRandom.uuid), version_none)
848
848
  end
849
849
 
850
850
  expect(read_events_forward(repository, count: 3)).to eq(events.first(3))
@@ -867,8 +867,8 @@ module RubyEventStore
867
867
  96c920b1-cdd0-40f4-907c-861b9fff7d02
868
868
  56404f79-0ba0-4aa0-8524-dc3436368ca0
869
869
  ].map{|id| SRecord.new(event_id: id) }
870
- repository.append_to_stream(events.first, stream, version_none)
871
- repository.append_to_stream(events.last, stream, version_0)
870
+ repository.append_to_stream([events.first], stream, version_none)
871
+ repository.append_to_stream([events.last], stream, version_0)
872
872
 
873
873
  expect(read_events_forward(repository, from: "96c920b1-cdd0-40f4-907c-861b9fff7d02")).to eq([events.last])
874
874
  expect(read_events_backward(repository, from: "56404f79-0ba0-4aa0-8524-dc3436368ca0")).to eq([events.first])
@@ -883,13 +883,13 @@ module RubyEventStore
883
883
 
884
884
  it 'does not allow same event twice in a stream' do
885
885
  repository.append_to_stream(
886
- SRecord.new(event_id: "a1b49edb-7636-416f-874a-88f94b859bef"),
886
+ [SRecord.new(event_id: "a1b49edb-7636-416f-874a-88f94b859bef")],
887
887
  stream,
888
888
  version_none
889
889
  )
890
890
  expect do
891
891
  repository.append_to_stream(
892
- SRecord.new(event_id: "a1b49edb-7636-416f-874a-88f94b859bef"),
892
+ [SRecord.new(event_id: "a1b49edb-7636-416f-874a-88f94b859bef")],
893
893
  stream,
894
894
  version_0
895
895
  )
@@ -898,13 +898,13 @@ module RubyEventStore
898
898
 
899
899
  it 'does not allow same event twice' do
900
900
  repository.append_to_stream(
901
- SRecord.new(event_id: "a1b49edb-7636-416f-874a-88f94b859bef"),
901
+ [SRecord.new(event_id: "a1b49edb-7636-416f-874a-88f94b859bef")],
902
902
  stream,
903
903
  version_none
904
904
  )
905
905
  expect do
906
906
  repository.append_to_stream(
907
- SRecord.new(event_id: "a1b49edb-7636-416f-874a-88f94b859bef"),
907
+ [SRecord.new(event_id: "a1b49edb-7636-416f-874a-88f94b859bef")],
908
908
  stream_other,
909
909
  version_none
910
910
  )
@@ -912,41 +912,39 @@ module RubyEventStore
912
912
  end
913
913
 
914
914
  it 'does not allow linking same event twice in a stream' do
915
- repository.append_to_stream([
916
- SRecord.new(event_id: "a1b49edb-7636-416f-874a-88f94b859bef"),
917
- ], stream,
915
+ repository.append_to_stream(
916
+ [SRecord.new(event_id: "a1b49edb-7636-416f-874a-88f94b859bef")],
917
+ stream,
918
918
  version_none
919
- ).link_to_stream("a1b49edb-7636-416f-874a-88f94b859bef", stream_flow, version_none)
919
+ ).link_to_stream(["a1b49edb-7636-416f-874a-88f94b859bef"], stream_flow, version_none)
920
920
  expect do
921
- repository.link_to_stream("a1b49edb-7636-416f-874a-88f94b859bef", stream_flow, version_0)
921
+ repository.link_to_stream(["a1b49edb-7636-416f-874a-88f94b859bef"], stream_flow, version_0)
922
922
  end.to raise_error(EventDuplicatedInStream)
923
923
  end
924
924
 
925
925
  it 'allows appending to GLOBAL_STREAM explicitly' do
926
926
  event = SRecord.new(event_id: "df8b2ba3-4e2c-4888-8d14-4364855fa80e")
927
- repository.append_to_stream(event, global_stream, version_any)
927
+ repository.append_to_stream([event], global_stream, version_any)
928
928
 
929
929
  expect(read_events_forward(repository, count: 10)).to eq([event])
930
930
  end
931
931
 
932
932
  specify "events not persisted if append failed" do
933
- repository.append_to_stream([
934
- SRecord.new,
935
- ], stream, version_none)
933
+ repository.append_to_stream([SRecord.new], stream, version_none)
936
934
 
937
935
  expect do
938
- repository.append_to_stream([
939
- SRecord.new(
940
- event_id: '9bedf448-e4d0-41a3-a8cd-f94aec7aa763'
941
- ),
942
- ], stream, version_none)
936
+ repository.append_to_stream(
937
+ [SRecord.new(event_id: '9bedf448-e4d0-41a3-a8cd-f94aec7aa763')],
938
+ stream,
939
+ version_none
940
+ )
943
941
  end.to raise_error(WrongExpectedEventVersion)
944
942
  expect(repository.has_event?('9bedf448-e4d0-41a3-a8cd-f94aec7aa763')).to be_falsey
945
943
  end
946
944
 
947
945
  specify 'linking non-existent event' do
948
946
  expect do
949
- repository.link_to_stream('72922e65-1b32-4e97-8023-03ae81dd3a27', stream_flow, version_none)
947
+ repository.link_to_stream(['72922e65-1b32-4e97-8023-03ae81dd3a27'], stream_flow, version_none)
950
948
  end.to raise_error do |err|
951
949
  expect(err).to be_a(EventNotFound)
952
950
  expect(err.event_id).to eq('72922e65-1b32-4e97-8023-03ae81dd3a27')
@@ -966,7 +964,7 @@ module RubyEventStore
966
964
  expect(binary.valid_encoding?).to eq(true)
967
965
 
968
966
  repository.append_to_stream(
969
- event = SRecord.new(data: binary, metadata: binary),
967
+ [event = SRecord.new(data: binary, metadata: binary)],
970
968
  stream,
971
969
  version_none
972
970
  )
@@ -1185,7 +1183,7 @@ module RubyEventStore
1185
1183
  stream_c = Stream.new('Stream C')
1186
1184
  repository.append_to_stream([event_1, event_2], stream_a, version_any)
1187
1185
  repository.append_to_stream([event_3], stream_b, version_any)
1188
- repository.link_to_stream(event_1.event_id, stream_c, version_none)
1186
+ repository.link_to_stream([event_1.event_id], stream_c, version_none)
1189
1187
 
1190
1188
  expect(repository.streams_of('8a6f053e-3ce2-4c82-a55b-4d02c66ae6ea')).to eq [stream_a, stream_c]
1191
1189
  expect(repository.streams_of('8cee1139-4f96-483a-a175-2b947283c3c7')).to eq [stream_a]
@@ -1281,7 +1279,7 @@ module RubyEventStore
1281
1279
 
1282
1280
  specify 'timestamp precision' do
1283
1281
  time = Time.utc(2020, 9, 11, 12, 26, 0, 123456)
1284
- repository.append_to_stream(SRecord.new(timestamp: time), stream, version_none)
1282
+ repository.append_to_stream([SRecord.new(timestamp: time)], stream, version_none)
1285
1283
  event = read_events_forward(repository, count: 1).first
1286
1284
 
1287
1285
  expect(event.timestamp).to eq(time)
@@ -114,4 +114,23 @@ RSpec.shared_examples :subscriptions do |subscriptions_class|
114
114
 
115
115
  expect(subscriptions.all_for('Test1DomainEvent')).to eq([handler, handler])
116
116
  end
117
+
118
+ it 'subscribes by type of event which is a class' do
119
+ handler = TestHandler.new
120
+ subscriptions.add_subscription(handler, [Test1DomainEvent])
121
+ subscriptions.add_thread_subscription(handler, [Test1DomainEvent])
122
+
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
+ end
117
136
  end
@@ -4,14 +4,15 @@ require 'concurrent'
4
4
 
5
5
  module RubyEventStore
6
6
  class Subscriptions
7
- def initialize
7
+ def initialize(event_type_resolver: default_event_type_resolver)
8
+ @event_type_resolver = event_type_resolver
8
9
  @local = LocalSubscriptions.new
9
10
  @global = GlobalSubscriptions.new
10
- @thread = ThreadSubscriptions.new
11
+ @thread = ThreadSubscriptions.new
11
12
  end
12
13
 
13
14
  def add_subscription(subscriber, event_types)
14
- local.add(subscriber, event_types)
15
+ local.add(subscriber, resolve_event_types(event_types))
15
16
  end
16
17
 
17
18
  def add_global_subscription(subscriber)
@@ -19,7 +20,7 @@ module RubyEventStore
19
20
  end
20
21
 
21
22
  def add_thread_subscription(subscriber, event_types)
22
- thread.local.add(subscriber, event_types)
23
+ thread.local.add(subscriber, resolve_event_types(event_types))
23
24
  end
24
25
 
25
26
  def add_thread_global_subscription(subscriber)
@@ -27,12 +28,25 @@ module RubyEventStore
27
28
  end
28
29
 
29
30
  def all_for(event_type)
30
- [local, global, thread].map{|r| r.all_for(event_type)}.reduce(&:+)
31
+ resolved_event_type = resolve_event_type(event_type)
32
+ [local, global, thread].map{|r| r.all_for(resolved_event_type)}.reduce(&:+)
31
33
  end
32
34
 
33
35
  private
34
36
  attr_reader :local, :global, :thread
35
37
 
38
+ def default_event_type_resolver
39
+ ->(value) { value.to_s }
40
+ end
41
+
42
+ def resolve_event_types(event_types)
43
+ event_types.map(&method(:resolve_event_type))
44
+ end
45
+
46
+ def resolve_event_type(type)
47
+ @event_type_resolver.call(type)
48
+ end
49
+
36
50
  class ThreadSubscriptions
37
51
  def initialize
38
52
  @local = ThreadLocalSubscriptions.new
@@ -51,8 +65,8 @@ module RubyEventStore
51
65
  end
52
66
 
53
67
  def add(subscription, event_types)
54
- event_types.each{ |type| @subscriptions[type.to_s] << subscription }
55
- ->() {event_types.each{ |type| @subscriptions.fetch(type.to_s).delete(subscription) } }
68
+ event_types.each{ |type| @subscriptions[type] << subscription }
69
+ ->() {event_types.each{ |type| @subscriptions.fetch(type).delete(subscription) } }
56
70
  end
57
71
 
58
72
  def all_for(event_type)
@@ -83,8 +97,8 @@ module RubyEventStore
83
97
  end
84
98
 
85
99
  def add(subscription, event_types)
86
- event_types.each{ |type| @subscriptions.value[type.to_s] << subscription }
87
- ->() {event_types.each{ |type| @subscriptions.value.fetch(type.to_s).delete(subscription) } }
100
+ event_types.each{ |type| @subscriptions.value[type] << subscription }
101
+ ->() {event_types.each{ |type| @subscriptions.value.fetch(type).delete(subscription) } }
88
102
  end
89
103
 
90
104
  def all_for(event_type)
@@ -4,23 +4,23 @@ module RubyEventStore
4
4
  class TransformKeys
5
5
  class << self
6
6
  def stringify(data)
7
- transform(data) {|k| k.to_s}
7
+ deep_transform(data, &:to_s)
8
8
  end
9
9
 
10
10
  def symbolize(data)
11
- transform(data) {|k| k.to_sym}
11
+ deep_transform(data, &:to_sym)
12
12
  end
13
13
 
14
14
  private
15
15
 
16
- def transform(data, &block)
16
+ def deep_transform(data, &block)
17
17
  data.each_with_object({}) do |(k, v), h|
18
18
  h[yield(k)] =
19
19
  case v
20
20
  when Hash
21
- transform(v, &block)
21
+ deep_transform(v, &block)
22
22
  when Array
23
- v.map{|i| Hash === i ? transform(i, &block) : i}
23
+ v.map{|i| Hash === i ? deep_transform(i, &block) : i}
24
24
  else
25
25
  v
26
26
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyEventStore
4
- VERSION = "2.0.3"
4
+ VERSION = "2.1.0"
5
5
  end
@@ -24,12 +24,11 @@ require 'ruby_event_store/mappers/in_memory_encryption_key_repository'
24
24
  require 'ruby_event_store/mappers/transformation/domain_event'
25
25
  require 'ruby_event_store/mappers/transformation/encryption'
26
26
  require 'ruby_event_store/mappers/transformation/event_class_remapper'
27
+ require 'ruby_event_store/mappers/transformation/upcast'
27
28
  require 'ruby_event_store/mappers/transformation/stringify_metadata_keys'
28
29
  require 'ruby_event_store/mappers/transformation/symbolize_metadata_keys'
29
- require 'ruby_event_store/mappers/transformation/serialization'
30
30
  require 'ruby_event_store/mappers/pipeline'
31
31
  require 'ruby_event_store/mappers/pipeline_mapper'
32
- require 'ruby_event_store/mappers/deprecated_wrapper'
33
32
  require 'ruby_event_store/mappers/default'
34
33
  require 'ruby_event_store/mappers/forgotten_data'
35
34
  require 'ruby_event_store/mappers/encryption_mapper'
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.0.3
4
+ version: 2.1.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-12-01 00:00:00.000000000 Z
11
+ date: 2021-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -30,17 +30,15 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 1.1.6
33
- description: Implementation of Event Store in Ruby
34
- email:
35
- - dev@arkency.com
33
+ description: |
34
+ Ruby implementation of an event store. Ships with in-memory event repository, generic instrumentation
35
+ and dispatches events synchronously.
36
+ email: dev@arkency.com
36
37
  executables: []
37
38
  extensions: []
38
- extra_rdoc_files: []
39
+ extra_rdoc_files:
40
+ - README.md
39
41
  files:
40
- - CHANGELOG.md
41
- - Gemfile
42
- - Gemfile.lock
43
- - Makefile
44
42
  - README.md
45
43
  - lib/ruby_event_store.rb
46
44
  - lib/ruby_event_store/batch_enumerator.rb
@@ -59,7 +57,6 @@ files:
59
57
  - lib/ruby_event_store/instrumented_repository.rb
60
58
  - lib/ruby_event_store/link_by_metadata.rb
61
59
  - lib/ruby_event_store/mappers/default.rb
62
- - lib/ruby_event_store/mappers/deprecated_wrapper.rb
63
60
  - lib/ruby_event_store/mappers/encryption_key.rb
64
61
  - lib/ruby_event_store/mappers/encryption_mapper.rb
65
62
  - lib/ruby_event_store/mappers/forgotten_data.rb
@@ -72,9 +69,9 @@ files:
72
69
  - lib/ruby_event_store/mappers/transformation/domain_event.rb
73
70
  - lib/ruby_event_store/mappers/transformation/encryption.rb
74
71
  - lib/ruby_event_store/mappers/transformation/event_class_remapper.rb
75
- - lib/ruby_event_store/mappers/transformation/serialization.rb
76
72
  - lib/ruby_event_store/mappers/transformation/stringify_metadata_keys.rb
77
73
  - lib/ruby_event_store/mappers/transformation/symbolize_metadata_keys.rb
74
+ - lib/ruby_event_store/mappers/transformation/upcast.rb
78
75
  - lib/ruby_event_store/metadata.rb
79
76
  - lib/ruby_event_store/null.rb
80
77
  - lib/ruby_event_store/projection.rb
@@ -94,12 +91,11 @@ files:
94
91
  - lib/ruby_event_store/subscriptions.rb
95
92
  - lib/ruby_event_store/transform_keys.rb
96
93
  - lib/ruby_event_store/version.rb
97
- - ruby_event_store.gemspec
98
94
  homepage: https://railseventstore.org
99
95
  licenses:
100
96
  - MIT
101
97
  metadata:
102
- homepage_uri: https://railseventstore.org/
98
+ homepage_uri: https://railseventstore.org
103
99
  changelog_uri: https://github.com/RailsEventStore/rails_event_store/releases
104
100
  source_code_uri: https://github.com/RailsEventStore/rails_event_store
105
101
  bug_tracker_uri: https://github.com/RailsEventStore/rails_event_store/issues
@@ -111,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
107
  requirements:
112
108
  - - ">="
113
109
  - !ruby/object:Gem::Version
114
- version: '0'
110
+ version: '2.5'
115
111
  required_rubygems_version: !ruby/object:Gem::Requirement
116
112
  requirements:
117
113
  - - ">="
@@ -121,5 +117,5 @@ requirements: []
121
117
  rubygems_version: 3.1.4
122
118
  signing_key:
123
119
  specification_version: 4
124
- summary: Event Store in Ruby
120
+ summary: Implementation of an event store in Ruby
125
121
  test_files: []
data/CHANGELOG.md DELETED
@@ -1,93 +0,0 @@
1
- Further changes can be tracked at [releases page](https://github.com/RailsEventStore/rails_event_store/releases).
2
-
3
- ### 0.14.0 (21.08.2017)
4
-
5
- * Change: Add lint for 3rd party implementations of dispatcher
6
- * Change: Deprecated MethodNotDefined error, use InvalidHandler instead
7
-
8
- ### 0.13.0 (15.10.2016)
9
-
10
- * Change: Dropped ClosedStruct event (meta)data wrapping PR #34
11
- Fix for Issue with ClosedStruct and object_id #33
12
- * Change: Refactor RubyEventStore::Client to have the same methods signatures as RailsEventStore::Client (PR #35),
13
- this will allow to remove most of the code form RailsEventStore::Client without breaking current
14
- applications that use RailsEventStore::Client. This change is however a breaking one for RubyEventStore.
15
-
16
- ### 0.12.1 (11.08.2016)
17
-
18
- * Fix: improve EventRepository specification tests (mutation tests)
19
-
20
- ### 0.12.0 (10.08.2016)
21
-
22
- * Change: all public methods arguments with default values are now keyword arguments
23
-
24
- ### 0.11.0 (12.07.2016)
25
-
26
- * Change: Call instead of handle_event, handle_event marked as deprecated in PR #18 is now removed PR #25
27
- * Change: Rename RubyEventStore::Facade to RubyEventStore::Client PR #26
28
-
29
- ### 0.10.1 (12.07.2016)
30
-
31
- * Added few new tests for repositories
32
-
33
- ### 0.10.0 (12.07.2016)
34
-
35
- * Fix: When using `append_to_stream`, expected version is no longer compared using `equal?` commit bdbe4600073d278cbf1024e8d49801fec768f6a7
36
- * Change: Creating events with data is now done using `data` keyword argument. Previously events were created using the syntax `OrderCreated.new(order_id: 123)`, now it has to be `OrderCreated.new(data: { order_id: 123 })`. PR #24
37
- * Change: Access to `data` attributes in an event is now using `event.data.some_attribute` syntax. `event.data[:some_attribute]` won't work either. PR #24
38
- * Change: Only events with the same name, event_id and data are equal - metadata is no longer taken into account PR #24
39
- * Change: `metadata[:timestamp]` is now set when event is appended to the stream, not when it is initialized PR #24
40
- * Change: Initialization of `RubyEventStore::Facade` is now using keyword arguments PR #24
41
- * Add support to `metadata_proc` PR #24
42
- * `ClosedStruct` is now a dependency PR #24
43
-
44
- ### 0.9.0 (24.06.2016)
45
-
46
- * Change: Call instead of handle_event, handle_event stays for now but is deprecated PR #18
47
- * Fix: Clarify Licensing terms #23 - MIT licence it is from now
48
-
49
- ### 0.8.0 (21.06.2016)
50
-
51
- * Change: Possibility to create projection based on all events PR #19
52
-
53
- ### 0.7.0 (21.06.2016)
54
-
55
- * Change: support for Dynamic subscriptions PR #20
56
- * Change: Add lint for 3rd party implementations of event broker PR #21
57
-
58
- ### 0.6.0 (25.05.2016)
59
-
60
- * Ability to provide a custom dispatcher to PubSub::Broker PR #12
61
- * Add support for projections PR #13
62
- * Added prettier message for case of missing #handle_event method. PR #14
63
- * Make file to run all the things PR #15
64
-
65
- ### 0.5.0 (21.03.2016)
66
-
67
- * Change: Event class refactoring to make default values more explicit PR #11
68
- * Change: No nils, use symbols instead - :any & :none replaced meaningless nil value
69
- * Change: Let event broker to be given as a dependency
70
- * Change: Remove Event#event_type - use class instead PR #10
71
-
72
- ### 0.4.0 (17.03.2016)
73
-
74
- * Change: Use class names to subscribe events PR #8
75
-
76
- ### 0.3.1 (13.03.2016)
77
-
78
- * Fix Don't overwrite timestamps when reading from repository
79
-
80
- ### 0.3.0 (03.03.2016)
81
-
82
- * Change: read_all_streams won't group_by results by stream name PR #4
83
- * Change: new way of define attributes of domain event PR #5
84
- * Change: reading forward and backward, refactored facade interface #6
85
- * Change: in memory event repository is now part of the gem, with shared specification PR #7
86
-
87
- ### 0.2.0 (27.01.2016)
88
-
89
- * Change: Return the event that the repository returns PR #2
90
-
91
- ### 0.1.0 (26.05.2015)
92
-
93
- Initial version
data/Gemfile DELETED
@@ -1,9 +0,0 @@
1
- source 'https://rubygems.org'
2
- git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
-
4
- gemspec
5
-
6
- eval_gemfile '../support/bundler/Gemfile.shared'
7
-
8
- gem 'activesupport', '6.0.3.4'
9
- gem 'concurrent-ruby', github: 'ruby-concurrency/concurrent-ruby', ref: 'c4cbc968c55e5b983dae953095761896220c46d1'
data/Gemfile.lock DELETED
@@ -1,121 +0,0 @@
1
- GIT
2
- remote: https://github.com/ruby-concurrency/concurrent-ruby.git
3
- revision: c4cbc968c55e5b983dae953095761896220c46d1
4
- ref: c4cbc968c55e5b983dae953095761896220c46d1
5
- specs:
6
- concurrent-ruby (1.1.7)
7
-
8
- PATH
9
- remote: .
10
- specs:
11
- ruby_event_store (2.0.3)
12
- concurrent-ruby (~> 1.0, >= 1.1.6)
13
-
14
- GEM
15
- remote: https://oss:7AXfeZdAfCqL1PvHm2nvDJO6Zd9UW8IK@gem.mutant.dev/
16
- specs:
17
- abstract_type (0.0.7)
18
- adamantium (0.2.0)
19
- ice_nine (~> 0.11.0)
20
- memoizable (~> 0.4.0)
21
- anima (0.3.2)
22
- abstract_type (~> 0.0.7)
23
- adamantium (~> 0.2)
24
- equalizer (~> 0.0.11)
25
- ast (2.4.1)
26
- concord (0.1.6)
27
- adamantium (~> 0.2.0)
28
- equalizer (~> 0.0.9)
29
- diff-lcs (1.4.4)
30
- equalizer (0.0.11)
31
- i18n (1.8.5)
32
- concurrent-ruby (~> 1.0)
33
- ice_nine (0.11.2)
34
- memoizable (0.4.2)
35
- thread_safe (~> 0.3, >= 0.3.1)
36
- minitest (5.14.2)
37
- mprelude (0.1.0)
38
- abstract_type (~> 0.0.7)
39
- adamantium (~> 0.2.0)
40
- concord (~> 0.1.5)
41
- equalizer (~> 0.0.9)
42
- ice_nine (~> 0.11.1)
43
- procto (~> 0.0.2)
44
- mutant-license (0.1.1.2.1627430819213747598431630701693729869473.0)
45
- parser (3.0.0.0)
46
- ast (~> 2.4.1)
47
- procto (0.0.3)
48
- rspec-core (3.10.1)
49
- rspec-support (~> 3.10.0)
50
- rspec-expectations (3.10.1)
51
- diff-lcs (>= 1.2.0, < 2.0)
52
- rspec-support (~> 3.10.0)
53
- rspec-mocks (3.10.1)
54
- diff-lcs (>= 1.2.0, < 2.0)
55
- rspec-support (~> 3.10.0)
56
- rspec-support (3.10.1)
57
- thread_safe (0.3.6)
58
- tzinfo (1.2.9)
59
- thread_safe (~> 0.1)
60
- unparser (0.5.6)
61
- abstract_type (~> 0.0.7)
62
- adamantium (~> 0.2.0)
63
- anima (~> 0.3.1)
64
- concord (~> 0.1.5)
65
- diff-lcs (~> 1.3)
66
- equalizer (~> 0.0.9)
67
- mprelude (~> 0.1.0)
68
- parser (>= 3.0.0)
69
- procto (~> 0.0.2)
70
- variable (0.0.1)
71
- equalizer (~> 0.0.11)
72
- zeitwerk (2.4.2)
73
-
74
- GEM
75
- remote: https://rubygems.org/
76
- specs:
77
- activesupport (6.0.3.4)
78
- concurrent-ruby (~> 1.0, >= 1.0.2)
79
- i18n (>= 0.7, < 2)
80
- minitest (~> 5.1)
81
- tzinfo (~> 1.1)
82
- zeitwerk (~> 2.2, >= 2.2.2)
83
- mutant (0.10.22)
84
- abstract_type (~> 0.0.7)
85
- adamantium (~> 0.2.0)
86
- anima (~> 0.3.1)
87
- ast (~> 2.2)
88
- concord (~> 0.1.5)
89
- diff-lcs (~> 1.3)
90
- equalizer (~> 0.0.9)
91
- ice_nine (~> 0.11.1)
92
- memoizable (~> 0.4.2)
93
- mprelude (~> 0.1.0)
94
- parser (~> 3.0.0)
95
- procto (~> 0.0.2)
96
- unparser (~> 0.5.6)
97
- variable (~> 0.0.1)
98
- mutant-rspec (0.10.22)
99
- mutant (= 0.10.22)
100
- rspec-core (>= 3.8.0, < 4.0.0)
101
- rake (13.0.3)
102
- rspec (3.10.0)
103
- rspec-core (~> 3.10.0)
104
- rspec-expectations (~> 3.10.0)
105
- rspec-mocks (~> 3.10.0)
106
-
107
- PLATFORMS
108
- ruby
109
-
110
- DEPENDENCIES
111
- activesupport (= 6.0.3.4)
112
- concurrent-ruby!
113
- mutant (~> 0.10.21)
114
- mutant-license!
115
- mutant-rspec (~> 0.10.21)
116
- rake (>= 10.0)
117
- rspec (~> 3.6)
118
- ruby_event_store!
119
-
120
- BUNDLED WITH
121
- 2.2.27
data/Makefile DELETED
@@ -1,32 +0,0 @@
1
- GEM_VERSION = $(shell cat ../RES_VERSION)
2
- GEM_NAME = ruby_event_store
3
- REQUIRE = $(GEM_NAME)
4
- IGNORE = RubyEventStore::InMemoryRepository\#with_synchronize \
5
- RubyEventStore::Client\#initialize \
6
- RubyEventStore::Client\#default_clock \
7
- RubyEventStore::Client\#default_correlation_id_generator \
8
- RubyEventStore::Client::Within\#add_thread_subscribers \
9
- RubyEventStore::Client::Within\#add_thread_global_subscribers \
10
- RubyEventStore::Client::Within\#call \
11
- RubyEventStore::Mappers::InMemoryEncryptionKeyRepository\#prepare_encrypt \
12
- RubyEventStore::Mappers::EncryptionKey\#prepare_encrypt \
13
- RubyEventStore::Mappers::EncryptionKey\#prepare_decrypt \
14
- RubyEventStore::Mappers::EncryptionKey\#prepare_auth_data \
15
- RubyEventStore::Mappers::EncryptionKey\#encrypt_authenticated \
16
- RubyEventStore::Mappers::EncryptionKey\#ciphertext_from_authenticated \
17
- RubyEventStore::Mappers::Default\#serializer \
18
- RubyEventStore::Mappers::JSONMapper\#serializer \
19
- RubyEventStore::Mappers::NullMapper\#serializer \
20
- RubyEventStore::Mappers::EncryptionMapper\#serializer \
21
- RubyEventStore::Mappers::PipelineMapper\#serializer \
22
- RubyEventStore::Mappers::DeprecatedWrapper\#serializer \
23
- RubyEventStore::Mappers::InstrumentedMapper\#serializer \
24
- RubyEventStore::Mappers::Transformation::Serialization*
25
-
26
- SUBJECT ?= RubyEventStore*
27
-
28
- include ../support/make/install.mk
29
- include ../support/make/test.mk
30
- include ../support/make/mutant.mk
31
- include ../support/make/gem.mk
32
- include ../support/make/help.mk
@@ -1,33 +0,0 @@
1
- module RubyEventStore
2
- module Mappers
3
- class DeprecatedWrapper
4
- def initialize(mapper)
5
- @mapper = mapper
6
- end
7
-
8
- def serializer
9
- @mapper.serializer
10
- end
11
-
12
- def event_to_record(any)
13
- @mapper.event_to_record(any)
14
- rescue NoMethodError => e
15
- raise unless e.message =~ /undefined method `event_to_record/
16
- warn <<~EOW
17
- Deprecation: Please rename #{@mapper.class}#event_to_serialized_record to #{@mapper.class}#event_to_record.
18
- EOW
19
- @mapper.event_to_serialized_record(any)
20
- end
21
-
22
- def record_to_event(any)
23
- @mapper.record_to_event(any)
24
- rescue NoMethodError => e
25
- raise unless e.message =~ /undefined method `record_to_event/
26
- warn <<~EOW
27
- Deprecation: Please rename #{@mapper.class}#serialized_record_to_event to #{@mapper.class}#record_to_event.
28
- EOW
29
- @mapper.serialized_record_to_event(any)
30
- end
31
- end
32
- end
33
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'yaml'
4
-
5
- module RubyEventStore
6
- module Mappers
7
- module Transformation
8
- class Serialization
9
- def initialize(serializer: YAML)
10
- warn <<~EOW
11
- #{self.class} has been deprecated and is effectively no-op. You should remove this transformation from your pipeline.
12
-
13
- Instead, pass the serializer directly to the repository and the scheduler. For example:
14
-
15
- Rails.configuration.event_store = RailsEventStore::Client.new(
16
- mapper: RubyEventStore::Mappers::Default.new,
17
- repository: RailsEventStoreActiveRecord::EventRepository.new(serializer: #{serializer}),
18
- dispatcher: RubyEventStore::ComposedDispatcher.new(
19
- RubyEventStore::ImmediateAsyncDispatcher.new(scheduler: ActiveJobScheduler.new(serializer: #{serializer}),
20
- RubyEventStore::Dispatcher.new
21
- )
22
- )
23
- EOW
24
- end
25
-
26
- def dump(item)
27
- item
28
- end
29
-
30
- def load(item)
31
- item
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,27 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'ruby_event_store/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'ruby_event_store'
8
- spec.version = RubyEventStore::VERSION
9
- spec.licenses = ['MIT']
10
- spec.authors = ['Arkency']
11
- spec.email = ['dev@arkency.com']
12
-
13
- spec.summary = %q{Event Store in Ruby}
14
- spec.description = %q{Implementation of Event Store in Ruby}
15
- spec.homepage = 'https://railseventstore.org'
16
- spec.metadata = {
17
- "homepage_uri" => "https://railseventstore.org/",
18
- "changelog_uri" => "https://github.com/RailsEventStore/rails_event_store/releases",
19
- "source_code_uri" => "https://github.com/RailsEventStore/rails_event_store",
20
- "bug_tracker_uri" => "https://github.com/RailsEventStore/rails_event_store/issues",
21
- }
22
-
23
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test/|spec/|features/|.mutant.yml)}) }
24
- spec.require_paths = ['lib']
25
-
26
- spec.add_dependency 'concurrent-ruby', '~> 1.0', '>= 1.1.6'
27
- end