Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Refactored PublisherConfirms.cs #549

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

Conversation

@jehrenzweig-captionhealth
Copy link
Contributor

@jehrenzweig-captionhealth jehrenzweig-captionhealth commented Feb 5, 2025

Refactored PublisherConfirms.cs:

  1. Deduped PublishMessagesInBatchAsync() method's batch publishing code
  2. Deleted outstandingMessageCount variable; use publishTasks.Count instead
  3. Fixed potential bug by setting minimum batch size to 1

* Deduped PublishMessagesInBatchAsync() method's batch publishing code
* Deleted outstandingMessageCount variable; use publishTasks.Count instead
* Fixed potential bug by setting minimum batch size to 1
if (outstandingMessageCount == batchSize)
// NOTE: [publishTasks] should be published after the final message has been added,
// even if the # of tasks it contains isn't equal to [batchSize].
if (publishTasks.Count == batchSize || i+1 == MESSAGE_COUNT)
Copy link
Contributor Author

@jehrenzweig-captionhealth jehrenzweig-captionhealth Feb 5, 2025
edited
Loading

Choose a reason for hiding this comment

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

The example originally contained duplicated code, to handle the case where publishTasks contained one or more items after the foreach(...) loop was exited, but it contained fewer items that the specified batch size (batchSize). The updated check should cover both cases & eliminate the need for the duplicated code.

There's also no need to check if publishTasks.Count > 0, because that statement will always be true.

Copy link
Collaborator

@lukebakken lukebakken Feb 5, 2025

Choose a reason for hiding this comment

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

Thanks, this is a bit more complex that I'd like so I'll push a change to your PR.

jehrenzweig-captionhealth reacted with thumbs up emoji
Copy link
Contributor

@michaelklishin michaelklishin left a comment

Choose a reason for hiding this comment

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

@lukebakken any objections to merging these?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@michaelklishin michaelklishin michaelklishin approved these changes

@lukebakken lukebakken lukebakken approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /