event_store_client 1.0.1 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/event_store_client/adapters/grpc/commands/persistent_subscriptions/read.rb +13 -3
- data/lib/event_store_client/adapters/grpc/commands/streams/link_to.rb +6 -2
- data/lib/event_store_client/client.rb +3 -5
- data/lib/event_store_client/deserialized_event.rb +1 -1
- data/lib/event_store_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 073a691ef952647fd7be92fad2526a279dccfe05867c524ccab6a86aee815dd2
|
4
|
+
data.tar.gz: 75c51d92577ceb57488e07761466dd58bf1b8cb52e23ee11a82d40bdfb387039
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9ba15429219f65fc9a7473642ff2e7a0c048cf14a0246f00ecac62ad5daf38ab9c0a800993911d14cd142706ec1d3f5e233e092279391c7c7d9d43683468a05
|
7
|
+
data.tar.gz: 27f4088d4e92c6a0cef51a93970559a4253d44789e5d9c3a744afebc59de027f3f1853e0c527de5438ede1031bd5cf9ad36aff2e6f8f82856202c23a45b47025
|
@@ -48,13 +48,23 @@ module EventStoreClient
|
|
48
48
|
private
|
49
49
|
|
50
50
|
def deserialize_event(entry)
|
51
|
+
id = entry.id.string
|
52
|
+
id = SecureRandom.uuid if id.nil? || id.empty?
|
53
|
+
|
54
|
+
data = (entry.data.nil? || entry.data.empty?) ? '{}' : entry.data
|
55
|
+
|
56
|
+
metadata =
|
57
|
+
JSON.parse(entry.custom_metadata || '{}').merge(
|
58
|
+
entry.metadata.to_h || {}
|
59
|
+
).to_json
|
60
|
+
|
51
61
|
config.mapper.deserialize(
|
52
62
|
EventStoreClient::Event.new(
|
53
|
-
id:
|
63
|
+
id: id,
|
54
64
|
title: "#{entry.stream_revision}@#{entry.stream_identifier.streamName}",
|
55
65
|
type: entry.metadata['type'],
|
56
|
-
data:
|
57
|
-
metadata:
|
66
|
+
data: data,
|
67
|
+
metadata: metadata
|
58
68
|
)
|
59
69
|
)
|
60
70
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'securerandom'
|
3
4
|
require 'grpc'
|
4
5
|
require 'event_store_client/adapters/grpc/generated/streams_pb.rb'
|
5
6
|
require 'event_store_client/adapters/grpc/generated/streams_services_pb.rb'
|
@@ -26,10 +27,13 @@ module EventStoreClient
|
|
26
27
|
|
27
28
|
event_metadata = event.metadata.tap do |h|
|
28
29
|
h['type'] = '$>'
|
29
|
-
h['content-type'] = 'application/
|
30
|
+
h['content-type'] = 'application/json'
|
30
31
|
h.delete('encryption')
|
31
32
|
end
|
32
33
|
|
34
|
+
event_id = event.id
|
35
|
+
event_id = SecureRandom.uuid if event.id.nil? || event.id.empty?
|
36
|
+
|
33
37
|
payload = [
|
34
38
|
request.new(
|
35
39
|
options: {
|
@@ -42,7 +46,7 @@ module EventStoreClient
|
|
42
46
|
request.new(
|
43
47
|
proposed_message: {
|
44
48
|
id: {
|
45
|
-
string:
|
49
|
+
string: event_id
|
46
50
|
},
|
47
51
|
data: event.title,
|
48
52
|
custom_metadata: custom_metadata,
|
@@ -10,9 +10,8 @@ module EventStoreClient
|
|
10
10
|
WrongExpectedEventVersion = Class.new(StandardError)
|
11
11
|
|
12
12
|
def publish(stream:, events:, options: {})
|
13
|
-
connection.append_to_stream(stream, events, options: options)
|
14
|
-
|
15
|
-
raise WrongExpectedEventVersion.new(e.message)
|
13
|
+
res = connection.append_to_stream(stream, events, options: options)
|
14
|
+
raise WrongExpectedEventVersion.new(e.message) if res.failure?
|
16
15
|
end
|
17
16
|
|
18
17
|
def read(stream, options: {})
|
@@ -43,7 +42,7 @@ module EventStoreClient
|
|
43
42
|
end
|
44
43
|
# rubocop:enable Metrics/CyclomaticComplexity
|
45
44
|
|
46
|
-
attr_accessor :connection
|
45
|
+
attr_accessor :connection
|
47
46
|
|
48
47
|
private
|
49
48
|
|
@@ -53,7 +52,6 @@ module EventStoreClient
|
|
53
52
|
@threads = []
|
54
53
|
@connection ||= EventStoreClient.adapter
|
55
54
|
@error_handler ||= config.error_handler
|
56
|
-
@service_name ||= 'default'
|
57
55
|
@broker ||= Broker.new(connection: connection)
|
58
56
|
@subscriptions ||= Subscriptions.new(connection: connection, service: config.service_name)
|
59
57
|
end
|
@@ -32,7 +32,7 @@ module EventStoreClient
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def content_type
|
35
|
-
return 'application/
|
35
|
+
return 'application/json' if EventStoreClient.config.adapter == :grpc
|
36
36
|
|
37
37
|
'application/vnd.eventstore.events+json'
|
38
38
|
end
|
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.0.
|
4
|
+
version: 1.0.6
|
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-02
|
11
|
+
date: 2021-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|