This is a does-one-thing module for making it easy to start or to adopt goroutines that need to respond gracefully to a soft termination request and then being able to wait for them to finish. Every time I've written a network service or other program that has some task-like pattern in it, I've wound up implementing some subset of the functionality below.

Supported use-cases:

  * accept() / poll() type APIs
  * Adopting already-spawned goroutines (e.g. from http.Server)
  * Channel-based notifications
  * Deferred cleanups
  * Nested task groups
  * Support for `runtime/trace` or other Context-creating modules
It's functionally complete, thoroughly documented with testable examples, and Apache-2.0 licensed.

Show HN: A Golang package for graceful task termination
github.com