NFIBrokerage / spear

A sharp EventStoreDB v20+ client backed by Mint :yum:
https://hex.pm/packages/spear
Apache License 2.0
87 stars 14 forks source link

store and read link information for reading projected streams #34

Closed the-mikedavis closed 3 years ago

the-mikedavis commented 3 years ago

closes #32

before this PR on machine:

iex> Spear.stream!(conn, "$ce-Spear.Test", chunk_size: 3) |> Enum.take(3)
[
  %Spear.Event{..}, # event 0 in category, 0 in stream
  %Spear.Event{..}, # event 1 in category, 0 in stream
  %Spear.Event{..}  # event 2 in category, 0 in stream
]
iex> event = List.last(v())
%Spear.Event{..} # event 2, 0 in stream
iex> Spear.stream!(conn, "$ce-Spear.Test", chunk_size: 2, from: event) |> Enum.take(2)
[
  %Spear.Event{..}, # event 0 in category, 0 in stream
  %Spear.Event{..}, # event 1 in category, 0 in stream
]

Because it would read the Spear.Event.metadata.revision field as 0 and think that was the revision of the projected stream.

This PR stores the link information from the read_resp in Spear.Event.metadata.link and uses it as the revision/position info for read requests (including subscriptions)