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

implement subscription, acks & nacks in persistent subscriptions API #24

Merged
merged 8 commits into from
Apr 21, 2021

Conversation

the-mikedavis
Copy link
Collaborator

this finishes off the persistent subscriptions API

connects #7
in conjunction with #23

was about as complicated as I assumed it'd be: needed to add a bit to Spear.Connection to allow bi-direction streaming

pretty nice to be able to reuse Spear.cancel_subscription/3 for psubs as well. it works because the cancel mechanism is via Mint.HTTP2.cancel_request/2 which just sends a GOAWAY frame that tells the server this request is done and don't send any more data on or receive any more data from this request stream

@the-mikedavis the-mikedavis self-assigned this Apr 21, 2021
Persistent.read_req_options(
stream_identifier: Shared.stream_identifier(streamName: stream_name),
group_name: group_name,
buffer_size: opts[:buffer_size],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with EventStore 20+ you control the in-flight buffer in the connect... function

in the tcp client this was a setting on the psub itself. this seems like a nice improvement because you might have multiple consumers some which can batch-process more events at once than others based on available resources

Comment on lines +124 to +129
messages =
if request.rpc.request_stream? and request.rpc.response_stream? do
message_buffer
else
[:eof | message_buffer]
end
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the important part of the change to the connection: making sure to never send :eof (which ends the request stream) for a bi-directional stream rpc like persistent.Read

rpc Read (stream ReadReq) returns (stream ReadResp);

@the-mikedavis the-mikedavis requested a review from a team April 21, 2021 20:07
@the-mikedavis the-mikedavis merged commit 28d6d16 into main Apr 21, 2021
@the-mikedavis the-mikedavis deleted the persistent branch April 21, 2021 20:55
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.

1 participant