ruby_event_store 1.1.1 → 1.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: 6c14775d70ee44777790b8b916ceee3b7801439494711a701aabb5a8904e8270
4
- data.tar.gz: 9c11cdd6cc8a13a8e16749928acb174c1cc11ca5a5e56aae2d9338fbbb42f842
3
+ metadata.gz: 6b30f1a52e6c803267914de53968b2885b7262c96f86e8399749ffcf189ad967
4
+ data.tar.gz: 9aa5d056ace06dec409e292e5562b3c6b177cdc4fceec2b98f1f936807b403cf
5
5
  SHA512:
6
- metadata.gz: 15c4530f8da5f71f6e411296a7e228ccea5dc0a3b836cfa90d7ba6c9f1462881d85963d1f68e0995f7b86bf27f9ae4981a551e3fbd1aa8b5213238488144ecba
7
- data.tar.gz: d925c31f958e72529c43fe4a006e74a0140b37bbddd667e1ac19cebca66963c59903a1aac136f1b080b2977b2019bb5e79c21bf9ab6bca5aa23c9f1db45293a8
6
+ metadata.gz: f953e8453922bbc437efafab4716533172d1e1c4c14d0c9ed3c426b569ef4b415edb9095ec95fa47ca70dd92412ab57489111f8d22e216a20033fc838b2bf4e9
7
+ data.tar.gz: b5ff8f63294fe88bcfe982ec494989c30f1748926990a68310a629b8eaa3c15b995c5ec015c373512c6f1ff3a6f46773d3f1c0f3a4a00b219fdb744f624c6ede
data/Makefile CHANGED
@@ -5,6 +5,7 @@ IGNORE = RubyEventStore::InMemoryRepository\#append_with_synchronize \
5
5
  RubyEventStore::Client::Within\#add_thread_subscribers \
6
6
  RubyEventStore::Client::Within\#add_thread_global_subscribers \
7
7
  RubyEventStore::Client::Within\#call \
8
+ RubyEventStore::Client\#default_correlation_id_generator \
8
9
  RubyEventStore::Mappers::InMemoryEncryptionKeyRepository\#prepare_encrypt \
9
10
  RubyEventStore::Mappers::EncryptionKey\#prepare_encrypt \
10
11
  RubyEventStore::Mappers::EncryptionKey\#prepare_decrypt \
@@ -4,17 +4,18 @@ require 'concurrent'
4
4
 
5
5
  module RubyEventStore
6
6
  class Client
7
-
8
7
  def initialize(repository:,
9
8
  mapper: Mappers::Default.new,
10
9
  subscriptions: Subscriptions.new,
11
10
  dispatcher: Dispatcher.new,
12
- clock: ->{ Time.now.utc })
11
+ clock: default_clock,
12
+ correlation_id_generator: default_correlation_id_generator)
13
13
  @repository = repository
14
14
  @mapper = mapper
15
15
  @broker = Broker.new(subscriptions: subscriptions, dispatcher: dispatcher)
16
16
  @clock = clock
17
17
  @metadata = Concurrent::ThreadLocalVar.new
18
+ @correlation_id_generator = correlation_id_generator
18
19
  end
19
20
 
20
21
 
@@ -30,7 +31,7 @@ module RubyEventStore
30
31
  append_to_stream_serialized_events(serialized_events, stream_name: stream_name, expected_version: expected_version)
31
32
  enriched_events.zip(serialized_events) do |event, serialized_event|
32
33
  with_metadata(
33
- correlation_id: event.metadata[:correlation_id] || event.event_id,
34
+ correlation_id: event.metadata.fetch(:correlation_id),
34
35
  causation_id: event.event_id,
35
36
  ) do
36
37
  broker.(event, serialized_event)
@@ -293,7 +294,8 @@ module RubyEventStore
293
294
 
294
295
  def enrich_event_metadata(event)
295
296
  metadata.each { |key, value| event.metadata[key] ||= value }
296
- event.metadata[:timestamp] ||= clock.call
297
+ event.metadata[:timestamp] ||= clock.call
298
+ event.metadata[:correlation_id] ||= correlation_id_generator.call
297
299
  end
298
300
 
299
301
  def append_to_stream_serialized_events(serialized_events, stream_name:, expected_version:)
@@ -306,6 +308,14 @@ module RubyEventStore
306
308
  @metadata.value = value
307
309
  end
308
310
 
309
- attr_reader :repository, :mapper, :broker, :clock
311
+ def default_clock
312
+ ->{ Time.now.utc }
313
+ end
314
+
315
+ def default_correlation_id_generator
316
+ ->{ SecureRandom.uuid }
317
+ end
318
+
319
+ attr_reader :repository, :mapper, :broker, :clock, :correlation_id_generator
310
320
  end
311
321
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyEventStore
4
- VERSION = "1.1.1"
4
+ VERSION = "1.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: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arkency
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-20 00:00:00.000000000 Z
11
+ date: 2020-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -105,7 +105,7 @@ metadata:
105
105
  changelog_uri: https://github.com/RailsEventStore/rails_event_store/releases
106
106
  source_code_uri: https://github.com/RailsEventStore/rails_event_store
107
107
  bug_tracker_uri: https://github.com/RailsEventStore/rails_event_store/issues
108
- post_install_message:
108
+ post_install_message:
109
109
  rdoc_options: []
110
110
  require_paths:
111
111
  - lib
@@ -120,8 +120,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  requirements: []
123
- rubygems_version: 3.0.3
124
- signing_key:
123
+ rubygems_version: 3.1.4
124
+ signing_key:
125
125
  specification_version: 4
126
126
  summary: Event Store in Ruby
127
127
  test_files: []