Skip to content

Commit 905e23f

Browse files
committed
Refine the runner doc comment
Signed-off-by: Michael Bridgen <[email protected]>
1 parent f53b260 commit 905e23f

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

controllers/leveltriggered/runner.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,22 @@ import (
66
"sync"
77
)
88

9-
// This is a dead simple way to run things using a manager's context as a base, so that they will
10-
// get shut down when the manager does. It must be constructed with `newRunner`, and added to a manager:
9+
// ctrl.Manager makes sure everything that is `Add`ed is started with a context, and cancels the context
10+
// to signal shutdown. But: all the runnables added share the same context, so they all get shut down at
11+
// the same time.
1112
//
12-
// r := newRunner()
13+
// `runner` is a dead simple way to run things with their own context, using a manager's context as a
14+
// base, so that they will get shut down when the manager does _and_ you can shut them down individually.
15+
// It must be constructed with `newRunner`, and added to a manager:
16+
//
17+
// r := newRunner(logger)
1318
// mgr.Add(r)
1419
//
1520
// then you can use it to run funcs:
1621
//
17-
// cancel := r.run(func(context.Context))
22+
// cancel := r.run(string, func(context.Context))
1823
//
19-
// The func will be run with its own context derived from the root context supplied by the manager,
24+
// The func will be run with its own context, derived from the root context supplied by the manager,
2025
// with the cancel func returned to the caller as shown. This way you can cancel the context yourself,
2126
// or let it be canceled when the manager shuts down.
2227
//

0 commit comments

Comments
 (0)