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

Document how to ensure durable write with event writer #239

Open
claudiofahey opened this issue Mar 9, 2021 · 2 comments
Open

Document how to ensure durable write with event writer #239

claudiofahey opened this issue Mar 9, 2021 · 2 comments
Assignees
Labels
documentation Improvements or additions to documentation Priority Should be prioritized

Comments

@claudiofahey
Copy link

Problem description
It is not clear how to use the event writer to determine when the event has been durably persisted.
Based on logging, writer.write_event(payload).await returns even before the event has been sent across the wire.

Problem location
EventStreamWriter.write_event() and
https://github.com/pravega/pravega-client-rust/blob/master/examples/event_write_and_read.rs#L65

Suggestions for an improvement
The documentation for EventStreamWriter.write_event() should be updated. Also, the example in event_write_and_read.rs should show how to await a durable write ack.

@Tristan1900
Copy link
Member

I see. In this code snippet

    let result = event_stream_writer.write_event(payload).await;
    assert!(result.await.is_ok());

the result is a channel that needs to await and when that has returned ok then event is durably persisted.
Will document that to avoid confusion.

@claudiofahey
Copy link
Author

This is not a very convenient API as it requires two awaits and then a match statement to flatten the result. It gets even more complicated without the anyhow macro.

let future = writer.write_event_by_routing_key(routing_key, event);
let receiver = future.await;
let result = receiver.await; // Result<Result<(), SegmentWriterError> RecvError>
let flattened_result = match result { // Result<(), Error>
    Ok(r) => r.map_err(|e| anyhow!(e)),
    Err(e) => Err(anyhow!(e)),
};

Is there anyway to get rid of the intermediate future? What is the benefit of it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation Priority Should be prioritized
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants