Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/exaring/contextflight
singleflight wrapper supporting contexts
https://github.com/exaring/contextflight
Last synced: 2 months ago
JSON representation
singleflight wrapper supporting contexts
- Host: GitHub
- URL: https://github.com/exaring/contextflight
- Owner: exaring
- License: apache-2.0
- Created: 2021-09-15T21:14:27.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-09-21T14:12:24.000Z (over 3 years ago)
- Last Synced: 2024-08-03T13:14:57.348Z (5 months ago)
- Language: Go
- Size: 14.6 KB
- Stars: 5
- Watchers: 9
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - contextflight - singleflight wrapper supporting contexts (Tool-kits & helpers)
README
![CI status](https://github.com/exaring/contextflight/actions/workflows/go.yml/badge.svg)
[![Go Report Card](https://goreportcard.com/badge/github.com/exaring/contextflight)](https://goreportcard.com/report/github.com/exaring/contextflight)# contextflight
`contextflight` is a thin wrapper around [singleflight](https://pkg.go.dev/golang.org/x/sync/singleflight) that adds
context handling.It works like `singleflight`, with the addition that the provided function receives a `context.Context`, which will
be cancelled when _all_ waiting callers' contexts are cancelled.This allows for correctly cancelling an expensive operation inside of singleflight only when _all_ requesters have
canceled their requests.