Global Partition Resolver is ignored#7
Merged
YanGusik merged 4 commits intoYanGusik:mainfrom Jan 28, 2026
Merged
Conversation
Removed the getPartitionKey method and its documentation.
Add additional checks for partition key resolution based on job properties.
Owner
|
Thanks for this PR! You've correctly identified the issue - the global However, I think the order of checks in Proposed order: protected function resolvePartition($job): string
{
// 1. Explicitly set via onPartition()
if (isset($job->partitionKey)) {
return (string) $job->partitionKey;
}
// 2. Overridden in job class (now works correctly without trait method!)
if (method_exists($job, 'getPartitionKey')) {
return (string) $job->getPartitionKey();
}
// 3. Global resolver from config
if (isset($this->partitionResolver)) {
return (string) ($this->partitionResolver)($job);
}
// 4. Auto-detect from common properties
foreach (['userId', 'user_id', 'tenantId', 'tenant_id'] as $prop) {
if (property_exists($job, $prop) && $job->$prop !== null) {
return (string) $job->$prop;
}
}
return 'default';
}This way:
Could you update the PR with this order? Thanks! |
Adjust the order of checks in resolvePartition(). The current PR checks properties before the getPartitionKey() method, which could break existing code where users override getPartitionKey() in their jobs. This way: * onPartition() has highest priority (explicit) * Custom getPartitionKey() in job classes still works * Global resolver finally works as a fallback * Auto-detection from properties is the last resort
…ess to it from the BalancedRedisQueue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I think the trait should not implement the getPartitionKey method, leaving it to the actual jobs, and the property checks should maybe be moved to the BalancedRedisQueue@resolvePartition(), before the method checks.
Fixes #6