event_store_client 2.1.3 → 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: cf7ad41170584cd3dbe64ba7afff6e8e3af7a51277cf60e5732b6187e18e8170
4
- data.tar.gz: 2cb382ee414a9d00373954e05f6a931e9bec042a84491dd58d2d96f4fd47559c
3
+ metadata.gz: d4ff17cd8c1913a09f27fd8ae0c846309b54d984ca81faa8291b769357ead3ec
4
+ data.tar.gz: b658667a55cc43ba62995e1369e4b8b0f2ee2c950b08dc5dfd19da75e1af430f
5
5
  SHA512:
6
- metadata.gz: adec2fceef915b4383e694f299e91963bd27bebcf6b3bcf5a25d8549bc6b6038a2d58ab1937444a8ffa3fd8785ed6f8351ec9b9960537a4d4000d3f7ce80d6c0
7
- data.tar.gz: ad2b082b49f5c6d40f6f74bf5e31543878b1d09787650381687eb1b9367aecbc80121d277f929a242e26e7f82d15dede426dc0da983ced71712b87497a3ede36
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EventStoreClient
4
- VERSION = '2.1.3'
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.3
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-26 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