event_store_client 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/docs/appending_events.md +4 -6
- data/docs/catch_up_subscriptions.md +2 -4
- data/docs/configuration.md +6 -8
- data/docs/deleting_streams.md +1 -3
- data/docs/encrypting_events.md +1 -3
- data/docs/linking_events.md +4 -6
- data/docs/reading_events.md +2 -4
- data/lib/event_store_client/errors.rb +31 -16
- data/lib/event_store_client/rspec/has_option_matcher.rb +88 -0
- data/lib/event_store_client/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82b73db66b7feef1d17e010f9e410476ab900bd6b137af03ee57106f2aefea6b
|
4
|
+
data.tar.gz: 926d40bfa51a581de7f9e7942d7092e4e0f0d7c23d1c932cb689946ef3a690f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59dc478314bb1a15895dfe851248d6c1b62a381c26d03c8f7d1d18465a1407a28f007a959f2c655222b54dd310929df5430528125c3c97221393e3ce3b937256
|
7
|
+
data.tar.gz: bb92b9f60639f5d0552c69b493e0e6dbb8e6985e89d7f4f78de6df45c12e6098554e7de13f8880e45fd84a8ddc8528eec778a78715ebd591fcc5c331709bea4a
|
data/README.md
CHANGED
data/docs/appending_events.md
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
# Append your first event
|
1
|
+
# Appending Events
|
4
2
|
|
5
3
|
## Append your first event
|
6
4
|
|
@@ -15,10 +13,10 @@ event = SomethingHappened.new(
|
|
15
13
|
)
|
16
14
|
|
17
15
|
begin
|
18
|
-
EventStoreClient.client.append_to_stream('some-stream', event)
|
16
|
+
EventStoreClient.client.append_to_stream('some-stream', event)
|
19
17
|
# => EventStore::Client::Streams::AppendResp
|
20
18
|
rescue EventStoreClient::WrongExpectedVersionError => e
|
21
|
-
puts e.message
|
19
|
+
puts e.message
|
22
20
|
end
|
23
21
|
```
|
24
22
|
|
@@ -38,7 +36,7 @@ event2 = SomethingHappened.new(
|
|
38
36
|
)
|
39
37
|
|
40
38
|
begin
|
41
|
-
EventStoreClient.client.append_to_stream('some-stream', [event1, event2])
|
39
|
+
EventStoreClient.client.append_to_stream('some-stream', [event1, event2])
|
42
40
|
# => Array<EventStore::Client::Streams::AppendResp>
|
43
41
|
rescue EventStoreClient::WrongExpectedVersionError => e
|
44
42
|
puts e.message
|
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
# Catch-up subscriptions
|
1
|
+
# Catch-up Subscriptions
|
4
2
|
|
5
3
|
Subscriptions allow you to subscribe to a stream and receive notifications about new events added to the stream.
|
6
4
|
|
@@ -111,7 +109,7 @@ An application, which hosts the subscription, can go offline for a period of tim
|
|
111
109
|
checkpoint = :start
|
112
110
|
handler = proc do |event|
|
113
111
|
handle_event(event)
|
114
|
-
checkpoint = event.stream_revision
|
112
|
+
checkpoint = event.stream_revision
|
115
113
|
end
|
116
114
|
|
117
115
|
EventStoreClient.client.subscribe_to_stream('some-stream', handler: handler, options: { from_revision: checkpoint })
|
data/docs/configuration.md
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# @title Configuration
|
2
|
-
|
3
1
|
# Configuration
|
4
2
|
|
5
3
|
Configuration options:
|
@@ -28,9 +26,9 @@ end
|
|
28
26
|
the resulting `channel_args` value will be
|
29
27
|
|
30
28
|
```ruby
|
31
|
-
{
|
32
|
-
"grpc.min_reconnect_backoff_ms" => 200,
|
33
|
-
"grpc.max_reconnect_backoff_ms" => 100,
|
29
|
+
{
|
30
|
+
"grpc.min_reconnect_backoff_ms" => 200,
|
31
|
+
"grpc.max_reconnect_backoff_ms" => 100,
|
34
32
|
"grpc.initial_reconnect_backoff_ms" => 100
|
35
33
|
}
|
36
34
|
```
|
@@ -39,7 +37,7 @@ This behaviour is intentional. So, if you want to override them all - you should
|
|
39
37
|
|
40
38
|
```ruby
|
41
39
|
EventStoreClient.configure do |config|
|
42
|
-
config.channel_args = {
|
40
|
+
config.channel_args = {
|
43
41
|
'grpc.min_reconnect_backoff_ms' => 500,
|
44
42
|
'grpc.max_reconnect_backoff_ms' => 500,
|
45
43
|
'grpc.initial_reconnect_backoff_ms' => 500
|
@@ -139,7 +137,7 @@ EventStoreClient.configure(name: :es_db_1) do |config|
|
|
139
137
|
end
|
140
138
|
EventStoreClient.configure(name: :es_db_2) do |config|
|
141
139
|
# adjust your second config here
|
142
|
-
config.eventstore_url = 'esdb://localhost:2114'
|
140
|
+
config.eventstore_url = 'esdb://localhost:2114'
|
143
141
|
end
|
144
142
|
```
|
145
143
|
|
@@ -162,7 +160,7 @@ Setup your default config:
|
|
162
160
|
```ruby
|
163
161
|
EventStoreClient.configure do |config|
|
164
162
|
# config goes here
|
165
|
-
config.eventstore_url = 'esdb://localhost:2113'
|
163
|
+
config.eventstore_url = 'esdb://localhost:2113'
|
166
164
|
end
|
167
165
|
```
|
168
166
|
|
data/docs/deleting_streams.md
CHANGED
data/docs/encrypting_events.md
CHANGED
data/docs/linking_events.md
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
# Linking events
|
1
|
+
# Linking Events
|
4
2
|
|
5
3
|
## Linking single event
|
6
4
|
|
@@ -20,7 +18,7 @@ EventStoreClient.client.append_to_stream(stream_name_1, event)
|
|
20
18
|
# Get persisted event
|
21
19
|
event = EventStoreClient.client.read(stream_name_1).first
|
22
20
|
# Link event from first stream into second stream
|
23
|
-
EventStoreClient.client.link_to(stream_name_2, event)
|
21
|
+
EventStoreClient.client.link_to(stream_name_2, event)
|
24
22
|
# => EventStore::Client::Streams::AppendResp
|
25
23
|
```
|
26
24
|
|
@@ -55,7 +53,7 @@ end
|
|
55
53
|
# Get persisted events
|
56
54
|
events = EventStoreClient.client.read(stream_name_1)
|
57
55
|
# Link events from first stream into second stream one by one
|
58
|
-
EventStoreClient.client.link_to(stream_name_2, events)
|
56
|
+
EventStoreClient.client.link_to(stream_name_2, events)
|
59
57
|
# => Array<EventStore::Client::Streams::AppendResp>
|
60
58
|
```
|
61
59
|
|
@@ -86,7 +84,7 @@ events = EventStoreClient.client.read(stream_name_1)
|
|
86
84
|
begin
|
87
85
|
EventStoreClient.client.link_to(stream_name_2, events, options: { expected_revision: :no_stream })
|
88
86
|
rescue EventStoreClient::WrongExpectedVersionError => e
|
89
|
-
puts e.message
|
87
|
+
puts e.message
|
90
88
|
end
|
91
89
|
```
|
92
90
|
|
data/docs/reading_events.md
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
# Reading events
|
1
|
+
# Reading Events
|
4
2
|
|
5
3
|
## Reading from a stream
|
6
4
|
|
@@ -63,7 +61,7 @@ In case a stream with given name does not exist - `EventStoreClient::StreamNotFo
|
|
63
61
|
|
64
62
|
```ruby
|
65
63
|
begin
|
66
|
-
EventStoreClient.client.read('non-existing-stream')
|
64
|
+
EventStoreClient.client.read('non-existing-stream')
|
67
65
|
rescue EventStoreClient::StreamNotFoundError => e
|
68
66
|
puts e.message # => Stream "non-existing-stream" does not exist.
|
69
67
|
puts e.stream_name # => "non-existing-stream"
|
@@ -48,28 +48,43 @@ module EventStoreClient
|
|
48
48
|
|
49
49
|
# @return [String]
|
50
50
|
def user_friendly_message
|
51
|
-
if wrong_expected_version.expected_stream_exists
|
52
|
-
|
53
|
-
|
54
|
-
if wrong_expected_version.expected_no_stream
|
55
|
-
return "Expected stream to be absent, but it actually exists."
|
56
|
-
end
|
57
|
-
if wrong_expected_version.current_no_stream
|
58
|
-
return <<~TEXT.strip
|
59
|
-
Stream revision #{wrong_expected_version.expected_revision.inspect} is expected, but \
|
60
|
-
stream does not exist.
|
61
|
-
TEXT
|
62
|
-
end
|
51
|
+
return expected_stream_exists if wrong_expected_version.expected_stream_exists
|
52
|
+
return expected_no_stream if wrong_expected_version.expected_no_stream
|
53
|
+
return current_no_stream if wrong_expected_version.current_no_stream
|
63
54
|
unless wrong_expected_version.expected_revision == wrong_expected_version.current_revision
|
64
|
-
return
|
65
|
-
Stream revision #{wrong_expected_version.expected_revision.inspect} is expected, but \
|
66
|
-
actual stream revision is #{wrong_expected_version.current_revision.inspect}.
|
67
|
-
TEXT
|
55
|
+
return unmatched_stream_revision
|
68
56
|
end
|
57
|
+
|
69
58
|
# Unhandled case. Could happen if something else would be added to proto and I don't add it
|
70
59
|
# here.
|
71
60
|
self.class.to_s
|
72
61
|
end
|
62
|
+
|
63
|
+
# @return [String]
|
64
|
+
def expected_stream_exists
|
65
|
+
"Expected stream to exist, but it doesn't."
|
66
|
+
end
|
67
|
+
|
68
|
+
# @return [String]
|
69
|
+
def expected_no_stream
|
70
|
+
"Expected stream to be absent, but it actually exists."
|
71
|
+
end
|
72
|
+
|
73
|
+
# @return [String]
|
74
|
+
def current_no_stream
|
75
|
+
<<~TEXT.strip
|
76
|
+
Stream revision #{wrong_expected_version.expected_revision.inspect} is expected, but \
|
77
|
+
stream does not exist.
|
78
|
+
TEXT
|
79
|
+
end
|
80
|
+
|
81
|
+
# @return [String]
|
82
|
+
def unmatched_stream_revision
|
83
|
+
<<~TEXT.strip
|
84
|
+
Stream revision #{wrong_expected_version.expected_revision.inspect} is expected, but \
|
85
|
+
actual stream revision is #{wrong_expected_version.current_revision.inspect}.
|
86
|
+
TEXT
|
87
|
+
end
|
73
88
|
end
|
74
89
|
|
75
90
|
class StreamDeletionError < Error
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This matcher is defined to test options which are defined by using
|
4
|
+
# EventStoreClient::Extensions::OptionsExtension option. Example:
|
5
|
+
# Let's say you have next class
|
6
|
+
# class SomeClass
|
7
|
+
# include EventStoreClient::Extensions::OptionsExtension
|
8
|
+
#
|
9
|
+
# option(:some_opt) { '1' }
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# To test that its instance has the proper option with the proper default value you can use this
|
13
|
+
# matcher:
|
14
|
+
# RSpec.describe SomeClass do
|
15
|
+
# subject { described_class.new }
|
16
|
+
#
|
17
|
+
# # Check that :some_opt is present
|
18
|
+
# it { is_expected.to have_option(:some_opt) }
|
19
|
+
# # Check that :some_opt is present and has the correct default value
|
20
|
+
# it { is_expected.to have_option(:some_opt).with_default_value('1') }
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# If you have more complex implementation of default value of your option - you should handle it
|
24
|
+
# customly. For example:
|
25
|
+
# class SomeClass
|
26
|
+
# include EventStoreClient::Extensions::OptionsExtension
|
27
|
+
#
|
28
|
+
# option(:some_opt) { calc_value }
|
29
|
+
# end
|
30
|
+
# You could test it like so:
|
31
|
+
# RSpec.described SomeClass do
|
32
|
+
# let(:instance) { described_class.new }
|
33
|
+
#
|
34
|
+
# describe ':some_opt default value' do
|
35
|
+
# subject { instance.some_opt }
|
36
|
+
#
|
37
|
+
# let(:value) { 'some val' }
|
38
|
+
#
|
39
|
+
# before do
|
40
|
+
# allow(instance).to receive(:calc_value).and_return(value)
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# it { is_expected.to eq(value) }
|
44
|
+
# end
|
45
|
+
# end
|
46
|
+
RSpec::Matchers.define :has_option do |option_name|
|
47
|
+
match do |obj|
|
48
|
+
option_presence = obj.class.respond_to?(:options) && obj.class.options.include?(option_name)
|
49
|
+
if @default_value
|
50
|
+
option_presence && obj.class.allocate.public_send(option_name) == @default_value
|
51
|
+
else
|
52
|
+
option_presence
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
failure_message do |obj|
|
57
|
+
option_presence = obj.class.respond_to?(:options) && obj.class.options.include?(option_name)
|
58
|
+
if option_presence && @default_value
|
59
|
+
msg = "Expected #{obj.class} to have `#{option_name.inspect}' option with #{@default_value.inspect}"
|
60
|
+
msg += ' default value, but default value is'
|
61
|
+
msg += " #{obj.class.allocate.public_send(option_name).inspect}"
|
62
|
+
else
|
63
|
+
msg = "Expected #{obj} to have `#{option_name.inspect}' option."
|
64
|
+
end
|
65
|
+
|
66
|
+
msg
|
67
|
+
end
|
68
|
+
|
69
|
+
description do
|
70
|
+
expected_list = RSpec::Matchers::EnglishPhrasing.list(expected)
|
71
|
+
sentences =
|
72
|
+
@chained_method_clauses.map do |(method_name, method_args)|
|
73
|
+
next '' if method_name == :required_kwargs
|
74
|
+
|
75
|
+
english_name = RSpec::Matchers::EnglishPhrasing.split_words(method_name)
|
76
|
+
arg_list = RSpec::Matchers::EnglishPhrasing.list(method_args)
|
77
|
+
" #{english_name}#{arg_list}"
|
78
|
+
end.join
|
79
|
+
|
80
|
+
"have#{expected_list} option#{sentences}"
|
81
|
+
end
|
82
|
+
|
83
|
+
chain :with_default_value do |val|
|
84
|
+
@default_value = val
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
RSpec::Matchers.alias_matcher :have_option, :has_option
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: event_store_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Wilgosz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grpc
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.12'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.12'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: simplecov
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -226,6 +226,7 @@ files:
|
|
226
226
|
- lib/event_store_client/mapper.rb
|
227
227
|
- lib/event_store_client/mapper/default.rb
|
228
228
|
- lib/event_store_client/mapper/encrypted.rb
|
229
|
+
- lib/event_store_client/rspec/has_option_matcher.rb
|
229
230
|
- lib/event_store_client/serialized_event.rb
|
230
231
|
- lib/event_store_client/serializer/event_deserializer.rb
|
231
232
|
- lib/event_store_client/serializer/event_serializer.rb
|
@@ -245,14 +246,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
245
246
|
requirements:
|
246
247
|
- - ">="
|
247
248
|
- !ruby/object:Gem::Version
|
248
|
-
version:
|
249
|
+
version: 3.0.0
|
249
250
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
250
251
|
requirements:
|
251
252
|
- - ">="
|
252
253
|
- !ruby/object:Gem::Version
|
253
254
|
version: '0'
|
254
255
|
requirements: []
|
255
|
-
rubygems_version: 3.
|
256
|
+
rubygems_version: 3.4.10
|
256
257
|
signing_key:
|
257
258
|
specification_version: 4
|
258
259
|
summary: Ruby integration for https://eventstore.org
|