-
Notifications
You must be signed in to change notification settings - Fork 129
[Core] feat: implement core change for group queue #1936
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
|
You are nearing your monthly Qodo Merge usage quota. For more information, please visit here. PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 3ee1d82
Previous suggestionsSuggestions
|
|||||||||||||||||||||||
Code Coverage Artifact 📈: https://github.com/port-labs/ocean/actions/runs/16617795812/artifacts/3646722014Code Coverage Total Percentage:
|
Code Coverage Artifact 📈: https://github.com/port-labs/ocean/actions/runs/16642869348/artifacts/3655915252Code Coverage Total Percentage:
|
|
Persistent suggestions updated to latest commit 3ee1d82 |
Code Coverage Artifact 📈: https://github.com/port-labs/ocean/actions/runs/16643906895/artifacts/3656269122Code Coverage Total Percentage:
|
Code Coverage Artifact 📈: https://github.com/port-labs/ocean/actions/runs/16644386130/artifacts/3656420807Code Coverage Total Percentage:
|
Code Coverage Artifact 📈: https://github.com/port-labs/ocean/actions/runs/16647488674/artifacts/3657498211Code Coverage Total Percentage:
|
Code Coverage Artifact 📈: https://github.com/port-labs/ocean/actions/runs/16647767834/artifacts/3657626476Code Coverage Total Percentage:
|
Code Coverage Artifact 📈: https://github.com/port-labs/ocean/actions/runs/16648522726/artifacts/3657885506Code Coverage Total Percentage:
|
matan84
left a comment
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.
Left comments
| self.group_key = group_key # str | None | ||
| self._queues: Dict[MaybeStr, Deque[T]] = defaultdict(deque) | ||
| self._locked: Set[MaybeStr] = set() | ||
| self._queue_not_empty = asyncio.Condition() |
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.
How do we make sure this isn't locking all events and does lock only events in a certain group?
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.
Or is the fact that this is only for a specific class instance enough to take care of that case
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.
I'll add a diagram
| loop = asyncio.get_event_loop() | ||
| config = ocean.integration.context.config | ||
|
|
||
| for path in self._event_queues.keys(): |
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.
How do we know that a group queue is being used? I think that the default is LocalQueue
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.
The group queue is defined per integration. by default it is LocalQueue, and the group_name_selector is defined per class integration.
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.
It's by integration or by kind?
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.
by integration
Co-authored-by: Matan <[email protected]>
Co-authored-by: Matan <[email protected]>
Co-authored-by: Matan <[email protected]>
Co-authored-by: Matan <[email protected]>
Co-authored-by: Matan <[email protected]>
Co-authored-by: Matan <[email protected]>
Co-authored-by: Matan <[email protected]>
shalev007
left a comment
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.
Looks good just some variable and comments renaming
Co-authored-by: Shalev Avhar <[email protected]>
Co-authored-by: Shalev Avhar <[email protected]>
matan84
left a comment
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.
LGTM, Make sure to cleanup all leftover comments
| loop = asyncio.get_event_loop() | ||
| config = ocean.integration.context.config | ||
|
|
||
| for path in self._event_queues.keys(): |
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.
It's by integration or by kind?
Code Coverage Artifact 📈: https://github.com/port-labs/ocean/actions/runs/16746037366/artifacts/3689532378Code Coverage Total Percentage:
|
User description
Description
Why
Problem: GitHub webhook events for the same resource (like a PR) were getting processed out of order when multiple workers ran concurrently. This broke temporal consistency - you'd get a "PR closed" event processed before "PR updated", leading to stale data.
Solution: Group events by resource ID and ensure only one worker processes events for any given resource at a time, while still allowing parallel processing across different resources.
What
Three core changes:
Group-based queuing: Added GroupQueue that partitions events by group_id and locks groups during processing
Resource identification: Created group_selector.py to extract consistent resource IDs from GitHub webhook payloads
Multi-worker coordination: Modified processor manager to spawn multiple workers that respect group locks
How
Resource Identification: Extract consistent IDs from GitHub events (e.g., pull_request-123, issue-456) to group related events together.
Group Queue: Queue implementation that enforces sequential processing within groups while allowing concurrent processing across groups. Workers lock groups on get() and unlock on commit().
Worker Pool: Multiple workers per webhook path, each pulling from the shared group queue. Integration automatically chooses group-aware or simple processing based on worker count configuration.
Result: Events for the same resource process in order, different resources process in parallel.
Type of change
Please leave one option from the following and delete the rest:
All tests should be run against the port production environment(using a testing org).
Core testing checklist
Integration testing checklist
examplesfolder in the integration directory.Preflight checklist
Screenshots
Overview of the flow:

Include screenshots from your environment showing how the resources of the integration will look.
API Documentation
Provide links to the API documentation used for this integration.
PR Type
Enhancement
Description
Implement group-based queue for ordered event processing
Add multi-worker support with group locking mechanism
Ensure sequential processing within resource groups
Enable parallel processing across different resource groups
Diagram Walkthrough
File Walkthrough
1 files
Add event workers configuration setting6 files
Export GroupQueue classAdd size method to queue interfaceImplement group-based queue with worker coordinationImplement size method for local queueReplace single processor with multi-worker systemAdd group_id field to webhook events1 files
Comprehensive test suite for group queue1 files
Document parallel queue implementation improvement1 files
Bump version to 0.26.2