Skip to content

feat: add CacheWriter interface with Abort method and WriteFunc helper#286

Merged
alecthomas merged 1 commit into
mainfrom
feat/cache-writer-abort
May 4, 2026
Merged

feat: add CacheWriter interface with Abort method and WriteFunc helper#286
alecthomas merged 1 commit into
mainfrom
feat/cache-writer-abort

Conversation

@alecthomas

Copy link
Copy Markdown
Collaborator

Replace the error-prone WithCancelCause/cancelCreate boilerplate at
Cache.Create call sites with a CacheWriter interface that manages
context cancellation internally.

  • Define client.CacheWriter (io.WriteCloser + Abort(error) error)
  • Alias as cache.Writer; update Cache.Create return type
  • Add cache.WriteFunc convenience wrapper
  • Each writer wraps context internally; Abort cancels and closes
  • Simplify ~10 call sites to use Abort instead of manual cancellation
  • Preserve existing external context cancellation semantics

Replace the error-prone WithCancelCause/cancelCreate boilerplate at
Cache.Create call sites with a CacheWriter interface that manages
context cancellation internally.

- Define client.CacheWriter (io.WriteCloser + Abort(error) error)
- Alias as cache.Writer; update Cache.Create return type
- Add cache.WriteFunc convenience wrapper
- Each writer wraps context internally; Abort cancels and closes
- Simplify ~10 call sites to use Abort instead of manual cancellation
- Preserve existing external context cancellation semantics
@alecthomas alecthomas requested a review from a team as a code owner May 4, 2026 17:46
@alecthomas alecthomas requested review from inez and removed request for a team May 4, 2026 17:46
@alecthomas alecthomas merged commit 5955fd4 into main May 4, 2026
8 checks passed
@alecthomas alecthomas deleted the feat/cache-writer-abort branch May 4, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant