event_store_client 2.1.2 → 2.1.4

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: 1b9b08383eb1a6c117cbb4a3c691395351a13fa471e6b86b7513297431cb2d03
4
- data.tar.gz: f56227663d39cb4a753bd7f01e6b56b41febda176ba82d4d9d7afdc848ee9429
3
+ metadata.gz: d4ff17cd8c1913a09f27fd8ae0c846309b54d984ca81faa8291b769357ead3ec
4
+ data.tar.gz: b658667a55cc43ba62995e1369e4b8b0f2ee2c950b08dc5dfd19da75e1af430f
5
5
  SHA512:
6
- metadata.gz: 402580786e13490581dc24e91a41bf2ac9c7d2846cd79cacd46b75c41fbce020808a6ed6cba615d191bc036f2afafeb49908ca2ee8d5b65cb7f6e63d9b8b69d3
7
- data.tar.gz: 98caa3a759cb2594087805e3eafa83141d4f9db797c0eff8266aeb188c24b04e1a74d8cb0df3c3cc967a144e61501f9307a93a06fa1ae14227c457987399d770
6
+ metadata.gz: 6ece79e50bb8a38629587ad87fc6b69e4dea30fd2edb83f34a5fbc5daa760eb11970a02475c6258769d3ba0c9b108bd0bec0464398885e8ae909884650f37047
7
+ data.tar.gz: 3cc3551a091362045c125b0ea1ef014a0f798a0683401c5c13a43688d570809a185f74d4f7f5e405f442101e906edd4e0f42282114d8e0910cae1cbbb9884635
@@ -117,7 +117,7 @@ module EventStoreClient
117
117
  # @param stream_name [String]
118
118
  # @return [Integer]
119
119
  def calc_next_position(raw_events, direction, stream_name)
120
- events = meaningful_events(raw_events).map { |e| e.event.event }
120
+ events = meaningful_events(raw_events).map(&:event)
121
121
 
122
122
  return next_position_for_all(events, direction) if stream_name == '$all'
123
123
 
@@ -128,18 +128,18 @@ module EventStoreClient
128
128
  # @param direction [Symbol] :Backwards or :Forwards
129
129
  # @return [Integer]
130
130
  def next_position_for_all(events, direction)
131
- return events.last.commit_position if direction == DEFAULT_READ_DIRECTION
131
+ return event_or_link(events.last).commit_position if direction == DEFAULT_READ_DIRECTION
132
132
 
133
- events.first.commit_position
133
+ event_or_link(events.first).commit_position
134
134
  end
135
135
 
136
136
  # @param events [Array<EventStore::Client::Streams::ReadResp::ReadEvent::RecordedEvent>]
137
137
  # @param direction [Symbol] :Backwards or :Forwards
138
138
  # @return [Integer]
139
139
  def next_position_for_regular(events, direction)
140
- return events.last.stream_revision + 1 if direction == DEFAULT_READ_DIRECTION
140
+ return event_or_link(events.last).stream_revision + 1 if direction == DEFAULT_READ_DIRECTION
141
141
 
142
- events.last.stream_revision - 1
142
+ event_or_link(events.last).stream_revision - 1
143
143
  end
144
144
 
145
145
  # @param raw_events [Array<EventStore::Client::Streams::ReadResp>]
@@ -166,6 +166,17 @@ module EventStoreClient
166
166
  "Current value is `#{max_count}'."
167
167
  )
168
168
  end
169
+
170
+ # Picks the correct object for later resolving of stream_revision from it. In case if we
171
+ # deal with links - we should prefer a link over a linked event, because exactly it
172
+ # contains correct stream revision of the stream we are reading from. Because if we pick
173
+ # a linked event's stream_revision, then it will be a revision from the stream that event
174
+ # belongs to - this can potentially create an infinite loop.
175
+ # @param event [EventStore::Client::Streams::ReadResp::ReadEvent]
176
+ # @return [EventStore::Client::Streams::ReadResp::ReadEvent::RecordedEvent]
177
+ def event_or_link(event)
178
+ event.link ? event.link : event.event
179
+ end
169
180
  end
170
181
  end
171
182
  end
@@ -34,8 +34,8 @@ module EventStoreClient
34
34
  def to_grpc
35
35
  {
36
36
  id: { string: id },
37
- data: serializer.serialize(data),
38
- custom_metadata: serializer.serialize(custom_metadata),
37
+ data: serializer.serialize(data).force_encoding('ASCII-8BIT'),
38
+ custom_metadata: serializer.serialize(custom_metadata).force_encoding('ASCII-8BIT'),
39
39
  metadata: metadata
40
40
  }
41
41
  end
@@ -19,7 +19,7 @@ module EventStoreClient
19
19
  # @param data [String, Object]
20
20
  # @return [String]
21
21
  def self.serialize(data)
22
- return data if data.is_a?(String)
22
+ return data.dup if data.is_a?(String)
23
23
 
24
24
  JSON.generate(data)
25
25
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EventStoreClient
4
- VERSION = '2.1.2'
4
+ VERSION = '2.1.4'
5
5
  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: 2.1.2
4
+ version: 2.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Wilgosz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-21 00:00:00.000000000 Z
11
+ date: 2022-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-monads