From 2619dfc4862dfca27053e57a7b493dff3534ac8f Mon Sep 17 00:00:00 2001 From: Michael Bridgen Date: Thu, 23 Nov 2023 19:32:09 +0000 Subject: [PATCH] Refine the `runner` doc comment Signed-off-by: Michael Bridgen --- controllers/leveltriggered/runner.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/controllers/leveltriggered/runner.go b/controllers/leveltriggered/runner.go index 5327011..5973b01 100644 --- a/controllers/leveltriggered/runner.go +++ b/controllers/leveltriggered/runner.go @@ -6,17 +6,22 @@ import ( "sync" ) -// This is a dead simple way to run things using a manager's context as a base, so that they will -// get shut down when the manager does. It must be constructed with `newRunner`, and added to a manager: +// ctrl.Manager makes sure everything that is `Add`ed is started with a context, and cancels the context +// to signal shutdown. But: all the runnables added share the same context, so they all get shut down at +// the same time. // -// r := newRunner() +// `runner` is a dead simple way to run things with their own context, using a manager's context as a +// base, so that they will get shut down when the manager does _and_ you can shut them down individually. +// It must be constructed with `newRunner`, and added to a manager: +// +// r := newRunner(logger) // mgr.Add(r) // // then you can use it to run funcs: // -// cancel := r.run(func(context.Context)) +// cancel := r.run(string, func(context.Context)) // -// The func will be run with its own context derived from the root context supplied by the manager, +// The func will be run with its own context, derived from the root context supplied by the manager, // with the cancel func returned to the caller as shown. This way you can cancel the context yourself, // or let it be canceled when the manager shuts down. //