Skip to content

Commit

Permalink
PR feedback: NoWait comment
Browse files Browse the repository at this point in the history
  • Loading branch information
levb committed May 14, 2024
1 parent 7f26cd6 commit 7805603
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions examples/jetstream/pull-consumer/c/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,20 @@ static natsStatus exampleFetchRequest(jsCtx *js, jsOptions *jsOpts)
s = js_PullSubscribe(&sub, js, SUBSCRIBE_SUBJECT, NULL, jsOpts, &so, &jerr);
}

// Use `natsSubscription_FetchRequest` to fetch the messages.
// Use `natsSubscription_FetchRequest` to fetch the messages. We set the
// batch size to 1000, but MaxBytes of 300 so we will only get 2 messages at
// a time.
//
// We set the batch size to 1000, but MaxBytes of 300 so we will only get 2
// messages at a time. Note that since we do not set NoWait, the call will
// block until the batch is filled or the timeout expires, unlike
// `natsSubscription_Fetch`.
// **Note**: Setting `.NoWait` causes the request to return as soon as there
// are some messages availabe, not necessarily the entire batch. By default,
// we wait `.Expires` time if there are not enough messages to make a full
// batch.
for (ibatch = 0, c = 0; (s == NATS_OK) && (c < NUM_MESSAGES); ibatch++)
{
int64_t start = nats_Now();
jsFetchRequest fr = {
.Batch = 1000,
// .NoWait = true,
/* .NoWait = true, */
.Expires = 500 * 1000 * 1000,
.MaxBytes = 300,
};
Expand Down

1 comment on commit 7805603

@github-actions
Copy link

Choose a reason for hiding this comment

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

Deploy preview for nats-by-example ready!

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

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

Please sign in to comment.