github.com/hemantjadon/runner (go): Package runner provides an idiomatic wrapper for managing long running tasks with requirement of single atomic runs and graceful atomic shutdowns.  Runner can be made by wrapping any runnable into the Runner type.  A runnable can be any type satisfying the interface.  The runnable must respect the ctx and should terminate when ctx completes.  Run() starts the runnable job with a ctx provided, whereas Close() cancels the ctx thereby shutting down the job.  Run() and Close() can be called concurrently, but the actual run and close of the job will be atomic (the main goal of the package). If called concurrently, only one of the calls to Run() and Close() will actually have impact, rest all the other calls will exit with ErrRunning and ErrStopping respectively.
Keywords: application|atomic|golang|graceful-shutdown|long-running