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

[Rust] Double Ack (Ack Ack) #241

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

[Rust] Double Ack (Ack Ack) #241

wants to merge 3 commits into from

Conversation

scottf
Copy link
Collaborator

@scottf scottf commented Jul 26, 2024

No description provided.

@scottf scottf requested a review from Jarema July 26, 2024 17:15
Copy link

github-actions bot commented Jul 26, 2024

Deploy preview for nats-by-example ready!

✅ Preview
https://nats-by-example-emnxxl1cv-connecteverything.vercel.app

Built with commit 2ab081b.
This pull request is being automatically deployed with vercel-action

Copy link
Contributor

@Jarema Jarema left a comment

Choose a reason for hiding this comment

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

Code-wise, this looks ok! It would be really good to explain in comment sections, like in other nats-by-examples, what are the differences between normal ack, and double ack so users know when to use which, and why.

println!("Consumer 1");
println!(" Start\n # pending messages: {}\n # messages with ack pending: {}", ci.num_pending, ci.num_ack_pending);

let message = consumer.fetch().max_messages(1).messages().await?.next().await.unwrap()?;
Copy link
Contributor

Choose a reason for hiding this comment

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

I would not unwrap the optional without comment here.
Let's explain to the user what is happening here: that messages() returns an iterator that is closed when None is returned.

maybe this is giving the user a better idea what is happening?

let fetch = consumer.fetch().max_messages(1).messages().await?;
let message = match fetch.next().await.expect("should get one message");

// Consumer 2 will use double_ack()
let stream = jetstream.get_stream("EVENTS".to_string()).await?;
let mut consumer = stream
.create_consumer(async_nats::jetstream::consumer::pull::Config { ..Default::default()})
Copy link
Contributor

Choose a reason for hiding this comment

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

I would put an explicit name for the consumer.

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.

2 participants