-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: add a timestamp component to qos in order to prioritize older/newer messages #148
Conversation
…ewer messages - 100% test cover for `internal/wrphandlers/qos` - added `PrioritizeOldest` options for qos - if `PrioritizeOldest` is false, then qos will favor the newest message during a qos value tie breaker (vice versa) - Updated `priorityQueue.trim()` to remove messages with the lowest qos value (taking `PrioritizeOldest` into account as well)
e525819
to
5e0befb
Compare
@@ -51,34 +64,69 @@ func (pq *priorityQueue) Enqueue(msg wrp.Message) error { | |||
return nil | |||
} | |||
|
|||
// trim removes messages with the lowest QualityOfService (taking `prioritizeOldest` into account) | |||
// until the queue no longer violates `maxQueueSize“. | |||
func (pq *priorityQueue) trim() { |
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.
Introduced this since we described a desire to keep messages with higher qos value taking the age of the message into account as well
|
||
// heap.Init() is required since the prioritization was switch to messages with the lowest QualityOfService. | ||
// The complexity of heap.Init() is O(n) where n = h.Len(). | ||
heap.Init(pq) |
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 we end up needing to trim often, then the O(n)
cost of heap.Init()
may start to sting...
I wanted to point that out in case we can't afford the O(n)
cost of heap.Init()
and we would rather trim() random messages instead.
internal/wrphandlers/qos
PrioritizeOldest
options for qosPrioritizeOldest
is false, then qos will favor the newest message during a qos value tie breaker (vice versa)- UpdatedpriorityQueue.trim()
to remove messages with the lowest qos value (takingPrioritizeOldest
into account as well)