Skip to content

Commit c769e58

Browse files
authored
Update GitHub Actions test.yaml workflow (#38)
* Update test.yaml * Fold in README updates from #36 (thanks, @amikai)
1 parent eee6e04 commit c769e58

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

.github/workflows/test.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ jobs:
6868
run: staticcheck ./...
6969

7070
- name: Run gofumpt
71+
if: matrix.platform != 'windows-latest' # :<
7172
run: gofumpt -d -e -l .
7273

74+
- name: Run revive
75+
run: revive --formatter=stylish ./...
76+
7377
- name: Run go test
7478
run: go test -v -race ./...

README.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# run
22

3-
[![GoDoc](https://godoc.org/github.com/oklog/run?status.svg)](https://godoc.org/github.com/oklog/run)
3+
[![GoDoc](https://godoc.org/github.com/oklog/run?status.svg)](https://godoc.org/github.com/oklog/run)
44
[![test](https://github.com/oklog/run/actions/workflows/test.yaml/badge.svg?branch=main&event=push)](https://github.com/oklog/run/actions/workflows/test.yaml)
55
[![Go Report Card](https://goreportcard.com/badge/github.com/oklog/run)](https://goreportcard.com/report/github.com/oklog/run)
66
[![Apache 2 licensed](https://img.shields.io/badge/license-Apache2-blue.svg)](https://raw.githubusercontent.com/oklog/run/master/LICENSE)
@@ -16,8 +16,8 @@ finally returns control to the caller only once all actors have returned. This
1616
general-purpose API allows callers to model pretty much any runnable task, and
1717
achieve well-defined lifecycle semantics for the group.
1818

19-
run.Group was written to manage component lifecycles in func main for
20-
[OK Log](https://github.com/oklog/oklog).
19+
run.Group was written to manage component lifecycles in func main for
20+
[OK Log](https://github.com/oklog/oklog).
2121
But it's useful in any circumstance where you need to orchestrate multiple
2222
goroutines as a unit whole.
2323
[Click here](https://www.youtube.com/watch?v=LHe1Cb_Ud_M&t=15m45s) to see a
@@ -62,14 +62,30 @@ g.Add(func() error {
6262
})
6363
```
6464

65+
### http.Server graceful Shutdown
66+
67+
```go
68+
httpServer := &http.Server{
69+
Addr: "localhost:8080",
70+
Handler: ...,
71+
}
72+
g.Add(func() error {
73+
return httpServer.ListenAndServe()
74+
}, func(error) {
75+
ctx, cancel := context.WithTimeout(context.TODO(), 3*time.Second)
76+
defer cancel()
77+
httpServer.Shutdown(ctx)
78+
})
79+
```
80+
6581
## Comparisons
6682

67-
Package run is somewhat similar to package
68-
[errgroup](https://godoc.org/golang.org/x/sync/errgroup),
83+
Package run is somewhat similar to package
84+
[errgroup](https://godoc.org/golang.org/x/sync/errgroup),
6985
except it doesn't require actor goroutines to understand context semantics.
7086

7187
It's somewhat similar to package
72-
[tomb.v1](https://godoc.org/gopkg.in/tomb.v1) or
88+
[tomb.v1](https://godoc.org/gopkg.in/tomb.v1) or
7389
[tomb.v2](https://godoc.org/gopkg.in/tomb.v2),
74-
except it has a much smaller API surface, delegating e.g. staged shutdown of
90+
except it has a much smaller API surface, delegating e.g. staged shutdown of
7591
goroutines to the caller.

0 commit comments

Comments
 (0)