-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
(2.12) Add Prioritized to the Consumer Priority Modes #7113
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
8a8298a
to
30229a0
Compare
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, just a couple small nitpicks
server/consumer.go
Outdated
wr.n-- | ||
|
||
if wr.n > 0 && wq.n > 1 { | ||
if wq.head.next == nil { |
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.
if wq.head.next == nil { | |
if wr.next == nil { |
server/consumer.go
Outdated
// Find insertion point - insert before first element with higher priority | ||
var prev *waitingRequest | ||
current := wq.head | ||
|
||
for current != nil { | ||
currentPriority := math.MaxInt32 | ||
if current.priorityGroup != nil { | ||
currentPriority = current.priorityGroup.Priority | ||
} | ||
// Insert before the first element with higher priority (stable sort) | ||
if currentPriority > priority { | ||
break | ||
} | ||
prev = current | ||
current = current.next | ||
} | ||
|
||
// Insert at found position | ||
if prev == nil { | ||
// Insert at head (lowest priority so far) | ||
wr.next = wq.head | ||
wq.head = wr | ||
} else { | ||
// Insert after prev | ||
wr.next = prev.next | ||
prev.next = wr | ||
if wr.next == nil { | ||
// We're the new tail | ||
wq.tail = wr | ||
} | ||
} |
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.
This same logic is also used in popAndRequeue
. Could perhaps extract this logic and reuse it in both insertSorted
and popAndRequeue
.
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.
Overall LGTM, can you please squash down & rebase on top of latest main
?
This adds Prioritized mode to the PriorityGroups, which allows for a low-latency switch between clients depending on priority set. Refer ADR-42 for more details. Signed-off-by: Tomasz Pietrek <[email protected]>
98a4c29
to
dbeca22
Compare
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
This adds Prioritized mode to the PriorityGroups, which allows for a low-latency switch between clients depending on priority set.
Refer ADR-42 for more details.
Signed-off-by: Tomasz Pietrek [email protected]