You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-21Lines changed: 20 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,44 +11,44 @@ Documentation available on [GoDoc](https://godoc.org/github.com/raksly/runner).
11
11
## Examples
12
12
### Minimalistic
13
13
```golang
14
-
runner:= runner.New(context.Background())
14
+
varr runner.Runner
15
15
16
-
runner.Run(runHTTP)
17
-
runner.Run(runTCP)
16
+
r.Run(runHTTP)
17
+
r.Run(runTCP)
18
18
19
-
runner.Wait()
19
+
r.Wait()
20
20
```
21
-
`runHTTP` and `runTCP` are both of type `func()`. `runner.Run` will run both functions in separate goroutines, and `runner.Wait()` waits until both functions exit.
21
+
`runHTTP` and `runTCP` are both of type `func()`. `r.Run` will run both functions in separate goroutines, and `r.Wait()` waits until both functions exit.
22
22
### Exit notification
23
23
When `runTCP` exits, it might be because the application is supposed to exit alltogether, or there was an irrecoverable error. In that case, you might want HTTP to exit aswell. `Run*` methods return a channel which is closed when its running function returns.
Both `runHTTP` and `runTCP` are now of type `func(context.Context)` and
37
-
are given the context passed to `runner.New`. If either `runHTTP` or `runTCP` returns, `select` will break, the context will be cancelled, making the other function exit aswell in due time, and `runner.Wait()` waits for that.
37
+
are given the context `Runner.Ctx`. If either `runHTTP` or `runTCP` returns, `select` will break, the context will be cancelled, making the other function exit aswell in due time, and `r.Wait()` waits for that.
38
38
### Signals
39
39
`Runner` contains a convenience method to work with OS signals
0 commit comments