event_store_client 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/event_store_client/adapters/grpc/client.rb +5 -3
- data/lib/event_store_client/adapters/grpc/commands/streams/read.rb +18 -1
- data/lib/event_store_client/catch_up_subscriptions.rb +4 -2
- data/lib/event_store_client/client.rb +1 -1
- data/lib/event_store_client/deserialized_event.rb +5 -3
- data/lib/event_store_client/event.rb +1 -1
- data/lib/event_store_client/mapper/default.rb +1 -0
- data/lib/event_store_client/mapper/encrypted.rb +2 -1
- data/lib/event_store_client/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 700f420a0fa9e3fb0352784f3bc0431cac18216130ba397897dfb77c98a4f7c6
|
4
|
+
data.tar.gz: e408f3a666dd7f1e95634591923bf8df51ce30c6b521cd9042072f551e5ff645
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2232248c19c04924effd9bab97271f5a0bf3e7b4cf4e56e5453fc32a27c56d587777239b48d0aafc026c265b1086691aa5e8c04e7863209d9bb1e07c046946e6
|
7
|
+
data.tar.gz: 2db191ee47dae6f22b5858ab85bde4d3129af6220f534d9b11e502150058c7211285afa2562aae70ae08877e21c8d2205c8d1400ec8365e10567e7c5295b7afc
|
@@ -84,10 +84,12 @@ module EventStoreClient
|
|
84
84
|
#
|
85
85
|
def listen(subscription, options: {})
|
86
86
|
consume_feed(subscription, options: options) do |event|
|
87
|
-
|
87
|
+
begin
|
88
|
+
yield event if block_given?
|
89
|
+
rescue StandardError => e
|
90
|
+
config.error_handler&.call(e)
|
91
|
+
end
|
88
92
|
end
|
89
|
-
rescue StandardError => e
|
90
|
-
config.error_handler&.call(e)
|
91
93
|
end
|
92
94
|
|
93
95
|
# Subscribe to a stream
|
@@ -44,7 +44,12 @@ module EventStoreClient
|
|
44
44
|
end
|
45
45
|
|
46
46
|
skip_decryption = options[:skip_decryption] || false
|
47
|
-
events =
|
47
|
+
events =
|
48
|
+
if options[:skip_deserialization]
|
49
|
+
read_stream_raw(opts)
|
50
|
+
else
|
51
|
+
read_stream(opts, skip_decryption)
|
52
|
+
end
|
48
53
|
Success(events)
|
49
54
|
rescue StreamNotFound
|
50
55
|
Failure(:not_found)
|
@@ -64,6 +69,18 @@ module EventStoreClient
|
|
64
69
|
raise GRPCUnavailableRetryFailed
|
65
70
|
end
|
66
71
|
|
72
|
+
def read_stream_raw(options)
|
73
|
+
retries ||= 0
|
74
|
+
service.read(request.new(options: options), metadata: metadata).map do |res|
|
75
|
+
raise StreamNotFound if res.stream_not_found
|
76
|
+
res.event.event
|
77
|
+
end
|
78
|
+
rescue ::GRPC::Unavailable
|
79
|
+
sleep config.grpc_unavailable_retry_sleep
|
80
|
+
retry if (retries += 1) <= config.grpc_unavailable_retry_count
|
81
|
+
raise GRPCUnavailableRetryFailed
|
82
|
+
end
|
83
|
+
|
67
84
|
def deserialize_event(entry, skip_decryption: false)
|
68
85
|
data = (entry.data.nil? || entry.data.empty?) ? '{}' : entry.data
|
69
86
|
|
@@ -5,6 +5,8 @@ module EventStoreClient
|
|
5
5
|
FILTER_DEFAULT_MAX = 32
|
6
6
|
FILTER_DEFAULT_CHECKPOINT_INTERVAL_MULTIPLIER = 10000
|
7
7
|
|
8
|
+
include Configuration
|
9
|
+
|
8
10
|
def create_or_load(subscriber, filter: {})
|
9
11
|
filter_options = prepare_filter_options(filter)
|
10
12
|
position = subscription_store.load_all_position(CatchUpSubscription.name(subscriber))
|
@@ -41,10 +43,10 @@ module EventStoreClient
|
|
41
43
|
logger&.info(msg)
|
42
44
|
break
|
43
45
|
end
|
44
|
-
rescue StandardError
|
46
|
+
rescue StandardError => e
|
45
47
|
subscription.position = old_position
|
46
48
|
subscription_store.update_position(subscription)
|
47
|
-
|
49
|
+
config.error_handler&.call(e)
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
@@ -11,7 +11,7 @@ module EventStoreClient
|
|
11
11
|
|
12
12
|
def publish(stream:, events:, options: {})
|
13
13
|
res = connection.append_to_stream(stream, events, options: options)
|
14
|
-
raise WrongExpectedEventVersion.new(
|
14
|
+
raise WrongExpectedEventVersion.new(res.failure) if res.failure?
|
15
15
|
res
|
16
16
|
end
|
17
17
|
|
@@ -15,14 +15,16 @@ module EventStoreClient
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def initialize(
|
19
|
-
validation = schema.call(args[:data] || {})
|
18
|
+
def initialize(args = {})
|
19
|
+
validation = schema.call(args[:data] || {}) unless args[:skip_validation]
|
20
20
|
@data = args.fetch(:data) { {} }
|
21
21
|
@metadata = args.fetch(:metadata) { {} }.merge(
|
22
22
|
'type' => self.class.name,
|
23
23
|
'content-type' => content_type
|
24
24
|
)
|
25
|
-
|
25
|
+
if !args[:skip_validation] && validation.errors.any?
|
26
|
+
@metadata.merge!('validation-errors' => validation.errors.to_h)
|
27
|
+
end
|
26
28
|
@type = args[:type] || self.class.name
|
27
29
|
@title = args[:title]
|
28
30
|
@id = args[:id]
|
@@ -51,7 +51,7 @@ module EventStoreClient
|
|
51
51
|
|
52
52
|
def deserialize(event, skip_decryption: false)
|
53
53
|
metadata = serializer.deserialize(event.metadata)
|
54
|
-
encryption_schema =
|
54
|
+
encryption_schema = metadata['encryption']
|
55
55
|
|
56
56
|
decrypted_data =
|
57
57
|
if skip_decryption
|
@@ -72,6 +72,7 @@ module EventStoreClient
|
|
72
72
|
end
|
73
73
|
|
74
74
|
event_class.new(
|
75
|
+
skip_validation: true,
|
75
76
|
id: event.id,
|
76
77
|
type: event.type,
|
77
78
|
title: event.title,
|
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: 1.
|
4
|
+
version: 1.3.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: 2021-
|
11
|
+
date: 2021-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|
@@ -262,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
262
262
|
- !ruby/object:Gem::Version
|
263
263
|
version: '0'
|
264
264
|
requirements: []
|
265
|
-
rubygems_version: 3.1.
|
265
|
+
rubygems_version: 3.1.0.pre1
|
266
266
|
signing_key:
|
267
267
|
specification_version: 4
|
268
268
|
summary: Ruby integration for https://eventstore.org
|