-
-
Notifications
You must be signed in to change notification settings - Fork 89
Add orderingKey option to SendActivityOptions
#544
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
This change exposes the orderingKey capability (added in PR fedify-dev#540) through the sendActivity() API, allowing applications to ensure ordered delivery of related activities. fedify-dev#536 Co-Authored-By: Claude <[email protected]>
Summary of ChangesHello @dahlia, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces the orderingKey option to SendActivityOptions, enabling ordered delivery of related activities to prevent race conditions. The changes include updating the SendActivityOptions interface, modifying message queue structures (FanoutMessage, OutboxMessage), and implementing the ordering logic within FederationImpl and InProcessMessageQueue. Comprehensive unit tests have been added to validate the new orderingKey behavior across different fanout scenarios. The documentation has also been updated to reflect this new capability and its usage. The implementation correctly handles the transformation of orderingKey for per-server ordering and gracefully falls back to individual enqueues when enqueueMany does not support per-message ordering keys, ensuring robust and correct behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR threads an orderingKey through the sendActivity() pipeline so that related activities can be processed sequentially per recipient server, reducing race conditions like “zombie posts”, and documents/tests this behavior.
Changes:
- Extend
FanoutMessage,OutboxMessage, andSendActivityOptionsto include an optionalorderingKey, and propagate it through fanout and outbox queues. - In the outbox path, derive a per-recipient-server key (
${orderingKey}\n${inboxOrigin}) to maintain ordering per remote origin while allowing cross-server parallelism. - Add documentation and tests that describe and verify
orderingKeybehavior and update the changelog to announce the new option.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
packages/fedify/src/federation/queue.ts |
Adds an optional orderingKey field to FanoutMessage and OutboxMessage so queued messages can carry ordering metadata end-to-end. |
packages/fedify/src/federation/middleware.ts |
Wires orderingKey through fanout and outbox processing, implements per-recipient-server ordering keys, and adjusts the internal options passed into FederationImpl.sendActivity(). |
packages/fedify/src/federation/middleware.test.ts |
Extends ContextImpl.sendActivity() tests to assert the orderingKey is preserved for fanout messages, transformed for outbox messages, and omitted when not specified. |
packages/fedify/src/federation/context.ts |
Exposes SendActivityOptions.orderingKey (with docs) and marks several existing options as readonly. |
docs/manual/send.md |
Documents how to use SendActivityOptions.orderingKey, including typical use cases and the per-server transformation behavior. |
CHANGES.md |
Notes the new SendActivityOptions.orderingKey option in the unreleased changes and links it to the relevant issues/PRs. |
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
Mirror the Promise.allSettled + aggregated logging approach used in the enqueueMany == null branch, so that all enqueue failures are reported with the same level of detail regardless of whether enqueueMany is used. fedify-dev#544 (comment) Co-Authored-By: Claude <[email protected]>
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces the orderingKey option to the SendActivityOptions interface, enabling ordered delivery of related activities. The changes include modifications to CHANGES.md, docs/manual/send.md, packages/fedify/src/federation/context.ts, packages/fedify/src/federation/middleware.test.ts, packages/fedify/src/federation/middleware.ts, and packages/fedify/src/federation/queue.ts. The code review identified a potential high-severity issue related to error handling in packages/fedify/src/federation/middleware.ts where the orderingKey is specified, and enqueueMany is not supported. This comment is retained as it does not conflict with the provided rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Since orderingKey is now available on ForwardActivityOptions via the Omit<SendActivityOptions, "fanout"> alias, forwardActivityInternal() should also support it to maintain consistency with sendActivity(). fedify-dev#544 (comment) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Summary
This PR exposes the
orderingKeycapability through thesendActivity()API, allowing applications to ensure ordered delivery of related activities and prevent race conditions like “zombie posts” (whereDeletearrives beforeCreate).Closes #536.
Changes
orderingKeyoption toSendActivityOptionsinterfaceorderingKeythrough fanout and outbox message queuesorderingKeyto${orderingKey}\n${inboxOrigin}at outbox stage for per-server ordering while maintaining cross-server parallelismorderingKeybehaviorUsage