improvement: Create an ItemSubmitter interface with de-duping and health checks #16
No reviewers
Labels
No labels
🤖 fix nits
🧠 ai fix nits
autorelease
bug
do not merge
documentation
duplicate
enhancement
good first issue
help wanted
invalid
merge when ready
no changelog
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
golibs/go-tasks!16
Loading…
Reference in a new issue
No description provided.
Delete branch "ksimons/addConsumer"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
✅ Successfully generated changelog entry!
Entry generated via PR title
To modify this entry, edit PR title using proper format.
📋Changelog Preview
💡 Improvements
Thanks! Core logic looks good, but some feedback around parameters and edge cases and a few questions.
@ -0,0 +1,126 @@// Copyright (c) 2025 Palantir Technologies. All rights reserved.Recommend updating name unless there's something particular to k8s about this
Should this be >=?
@ -0,0 +49,4 @@// processing happens asynchronously. Duplicate submissions are collapsed.Submit(context.Context, T)}type defaultItemSubmitter[T constraint] struct {@ -0,0 +89,4 @@for {element, shutdown := d.queue.Get()if shutdown {svc1log.FromContext(ctx).Warn("Queue shutting down; workers stopping.")Is there a particular reason that this is
Warnrather thanInfo? Just wondering, as it seems like this behavior might be expected in the normal operation.@ -0,0 +117,4 @@func (d defaultItemSubmitter[T]) handleProcessError(ctx context.Context, element T, err error) {numRequeues := d.queue.NumRequeues(element)ctx = svc1log.WithLoggerParams(ctx, svc1log.SafeParam("maxNumRequeues", d.maxNumRequeues), svc1log.SafeParam("numRequeues", numRequeues))d.logError(ctx, err)Should either check
d.logError != nilhere or update param to ensure that anilvalue cannot be set@ -0,0 +35,4 @@// Any value under 1 will cause 0 requeues to occurfunc WithMaxNumRequeues[T constraint](maxNumRequeues int) ItemSubmitterOption[T] {return itemSubmitterOptionFunc[T](func(defaultItemSubmitterArg *defaultItemSubmitter[T]) {defaultItemSubmitterArg.maxNumRequeues = maxNumRequeuesWhat is the behavior if the provided value is <=0?
@ -0,0 +46,4 @@if errorLogger == nil {return}defaultItemSubmitterArg.logError = errorLoggerPer other comment, need to either add a check here to ensure that
errorLoggeris notnilor add a check whenerrorLoggeris invoked to ensure that it is not invoked if it isnil.@ -37,16 +38,28 @@ type CollapsingQueue[T comparable] interface {// queue while it was being processed, it will be re-queued for another processingIs
Forgetthe standard nomenclature?ResetRateLimitseems more natural/understandable to me, but don't feel strongly about it so fine to keep the naming as well (just a question/suggestion).@ -0,0 +1,80 @@// Copyright (c) 2025 Palantir Technologies. All rights reserved.What is considered a "failure" here? It's not really clear from looking at the interface documentation. Looking at the implementation, it looks like it might be the case that any call to
Whenincrements the "failure" count? It's not really clear to me why that would be the case, though.@ -0,0 +64,4 @@if calculated > r.maxDelay {return r.maxDelay}return calculatedFine to leave as-is as well, but
minbuiltin can also be used:Released v0.6.0