improvement: Adding workerpool package and implementation #14
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!14
Loading…
Reference in a new issue
No description provided.
Delete branch "ksimons/workerPoolFinal"
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?
Generate changelog in
changelog/@unreleasedType (Select exactly one)
Description Ksimons/worker pool final
Check the box to generate changelog(s)
✅ Successfully generated changelog entry!
Entry generated via PR title
To modify this entry, edit PR title using proper format.
📋Changelog Preview
💡 Improvements
Submitted some feedback for
computing_future.go-- will look at worker pool files later.Should this be in another directory/package under
internalso that package name is not justinternal?yeah that makes more sense; done
Thanks -- mostly looks good. Minor feedback and questions.
@ -0,0 +1,45 @@// Copyright (c) 2025 Palantir Technologies. All rights reserved.@ -0,0 +30,4 @@if maxNumberOfThreads < 1 {return c}c.maxNumberOfWorkers = &maxNumberOfThreadsWhat is the behavior if the provided value is negative? Should probably either:
Should also document the behavior as well.
@ -0,0 +39,4 @@// Metrics will only be emitted for the pool if at least 1 tag is suppliedfunc WithMetricTags(tags []metrics.Tag) Option {return func(c *Config) *Config {c.tags = tagsIs it fine that we're using the provided slice directly rather than cloning? Current approach is not necessarily incorrect, but does mean that callers should generally not mutate the slice they provide here unless they want to modify behavior of the worker pool
@ -0,0 +1,171 @@// Copyright (c) 2025 Palantir Technologies. All rights reserved.Wouldn't
<=be safer in casemapSizesomehow grows beyondmaxNumberOfWorkers? Don't see locking around this logic so seems like it might be possible@ -0,0 +106,4 @@go d.startWorker(ctx)}func (d *defaultSupplierWorkerPool[R]) runWorkerLoop(workerContext context.Context) {@ -0,0 +39,4 @@// Metrics will only be emitted for the pool if at least 1 tag is suppliedfunc WithMetricTags(tags []metrics.Tag) Option {return func(c *Config) *Config {c.tags = tagsI think this is fine tbh
@ -0,0 +1,45 @@// Copyright (c) 2025 Palantir Technologies. All rights reserved.Sorry I missed this the first time around -- can we use
Workerssince that's more accurate@ -0,0 +27,4 @@// If a value of less than 1 is provided, it is ignoredfunc WithMaxNumberOfWorkers(maxNumberOfThreads int) Option {return func(c *Config) *Config {if maxNumberOfThreads < 1 {This should be fine, but just noting that this means that once a max has been configured, it's not possible to use this option function to configure back to "unlimited"
Released v0.5.0