Skip to content

Add WithResultCallback option to avoid unbounded result accumulation#114

Merged
rolinh merged 2 commits intomainfrom
pr/rolinh/callback
Apr 2, 2026
Merged

Add WithResultCallback option to avoid unbounded result accumulation#114
rolinh merged 2 commits intomainfrom
pr/rolinh/callback

Conversation

@rolinh
Copy link
Copy Markdown
Member

@rolinh rolinh commented Apr 1, 2026

Task results have always accumulated in memory until Drain is called, requiring callers to drain periodically to avoid unbounded growth. This change adds WithResultCallback, an option that processes each result as it completes, eliminating accumulation entirely.

This change is backwards compatible. New and NewWithContext accept variadic Option arguments, so existing callers require no changes.

Ref: #44 (comment)
Ref: #45

@rolinh rolinh added the kind/feature This introduces new functionality. label Apr 1, 2026
@rolinh rolinh force-pushed the pr/rolinh/callback branch from efa136d to 955b1f4 Compare April 1, 2026 14:38
Copy link
Copy Markdown
Member

@kaworu kaworu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch, I really like the direction. Some question about the implementation, nothing blocking.

Comment thread example_test.go Outdated
Comment thread workerpool.go
Comment thread workerpool.go
Comment thread workerpool.go
rolinh added 2 commits April 1, 2026 19:35
Task results have always accumulated in memory until Drain is called,
requiring callers to drain periodically to avoid unbounded growth. This
change adds WithResultCallback, an option that processes each result as
it completes, eliminating accumulation entirely.

This change is backwards compatible. New and NewWithContext accept
variadic Option arguments, so existing callers require no changes.

Signed-off-by: Robin Hahling <code@hahling.ch>
Suggested-by: Alexandre Perrin <alex@isovalent.com>
Signed-off-by: Robin Hahling <code@hahling.ch>
@rolinh rolinh force-pushed the pr/rolinh/callback branch from 955b1f4 to f7b8f74 Compare April 1, 2026 17:38
@rolinh rolinh requested a review from kaworu April 1, 2026 17:43
@rolinh rolinh merged commit 5570790 into main Apr 2, 2026
3 checks passed
@rolinh rolinh deleted the pr/rolinh/callback branch April 2, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature This introduces new functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants