Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add :filter support to stream!/3 and read_stream/3 #56

Merged
merged 1 commit into from
Sep 9, 2021

Conversation

the-mikedavis
Copy link
Collaborator

@the-mikedavis the-mikedavis commented Aug 26, 2021

requires #55
requires EventStore/EventStore#3133

allows one to pass a server-side filter when doing non-subscription stream reads, like so:

iex> Spear.stream!(conn, :all) |> Enum.count
20
iex> Spear.stream!(conn, :all, filter: Spear.Filter.exclude_system_types()) |> Enum.count
0

iex> import Spear.Filter
iex> filter = ~f[$projections-]ps
%Spear.Filter{by: ["$projections-"], checkpoint_after: 1024, on: :stream_name}
iex> Spear.stream!(conn, :all, filter: filter) |> Enum.count
11
iex> Spear.stream!(conn, :all, filter: filter) |> Enum.map(& &1.metadata.stream_name) |> Enum.uniq
["$projections-$all", "$projections-$by_event_type", "$projections-$streams",
 "$projections-$stream_by_category", "$projections-$by_category",
 "$projections-$by_correlation_id"]

iex> forward = Spear.stream!(conn, :all, filter: filter)
iex> backward = Spear.stream!(conn, :all, filter: filter, direction: :backwards, from: :end)
iex> Enum.to_list(forwards) == Enum.reverse(backwards)
true

This allows use to properly implement back-pressure to a filtered :all subscription in Volley.InOrderSubscription.

This feature awaits the next EventStoreDB release.

@the-mikedavis the-mikedavis marked this pull request as ready for review September 9, 2021 18:27
@the-mikedavis the-mikedavis requested a review from a team September 9, 2021 18:27
@the-mikedavis the-mikedavis merged commit bd5da44 into main Sep 9, 2021
@the-mikedavis the-mikedavis deleted the read-all-stream branch September 9, 2021 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants