Skip to content

feat: implement ReleaseContext for all pool types - #387

Merged
panjf2000 merged 3 commits into
devfrom
release-context
Mar 20, 2026
Merged

panjf2000 merged 3 commits into
devfrom
release-context

Conversation

@panjf2000

Copy link
Copy Markdown
Owner

Fixes #384

Copilot AI review requested due to automatic review settings March 20, 2026 12:05
@codecov

codecov Bot commented Mar 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.46835% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.66%. Comparing base (0b77168) to head (7b5b5df).
⚠️ Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
ants.go 84.61% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #387      +/-   ##
==========================================
+ Coverage   94.54%   94.66%   +0.12%     
==========================================
  Files          14       14              
  Lines         788      863      +75     
==========================================
+ Hits          745      817      +72     
- Misses         32       33       +1     
- Partials       11       13       +2     
Flag Coverage Δ
unittests 94.66% <97.46%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new ReleaseContext(ctx context.Context) error shutdown API across the pool types, enabling graceful pool release that can be canceled/abandoned via a shared context (e.g., with http.Server.Shutdown), addressing feature request #384.

Changes:

  • Add ReleaseContext to poolCommon (and expose it via the package-level default pool API).
  • Add ReleaseContext to multi-pool variants (MultiPool, MultiPoolWithFunc, MultiPoolWithFuncGeneric), delegating to underlying pools and aggregating per-pool errors.
  • Add tests covering default pool and multi-pool ReleaseContext behavior (including a nil-context case).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ants.go Adds ReleaseContext for the default pool and implements (*poolCommon).ReleaseContext.
multipool.go Adds (*MultiPool).ReleaseContext that releases all sub-pools concurrently and aggregates errors.
multipool_func.go Adds (*MultiPoolWithFunc).ReleaseContext with the same pattern as ReleaseTimeout.
multipool_func_generic.go Adds (*MultiPoolWithFuncGeneric).ReleaseContext with the same pattern as ReleaseTimeout.
ants_test.go Adds test coverage for ReleaseContext on default pool, nil context behavior, and multi-pool variants.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ants.go Resolved
Comment thread ants_test.go Resolved
Comment thread ants.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ants_test.go Resolved
Comment thread multipool.go Resolved
Comment thread multipool_func.go Resolved
Comment thread multipool_func_generic.go Resolved
Comment thread ants.go Resolved
Comment thread ants_test.go Resolved
Comment thread ants_test.go Resolved
@panjf2000
panjf2000 merged commit 8036c99 into dev Mar 20, 2026
13 checks passed
@panjf2000
panjf2000 deleted the release-context branch March 20, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: 建议增加一个ReleaseContext(ctx context.Context) error

2 participants

⌂ 换网址