Skip to content

Commit fa765e5

Browse files
Fixed Runner type to be exported.
1 parent f2b7098 commit fa765e5

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

chapter7/patterns/runner/runner.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import (
1212
"time"
1313
)
1414

15-
// runner runs a set of tasks within a given timeout and can be
15+
// Runner runs a set of tasks within a given timeout and can be
1616
// shut down on an operating system interrupt.
17-
type runner struct {
17+
type Runner struct {
1818
// interrupt channel reports a signal from the
1919
// operating system.
2020
interrupt chan os.Signal
@@ -31,8 +31,8 @@ type runner struct {
3131
}
3232

3333
// New returns a new ready-to-use runner.
34-
func New(d time.Duration) *runner {
35-
return &runner{
34+
func New(d time.Duration) *Runner {
35+
return &Runner{
3636
interrupt: make(chan os.Signal, 1),
3737
complete: make(chan error),
3838
timeout: time.After(d * time.Second),
@@ -41,12 +41,12 @@ func New(d time.Duration) *runner {
4141

4242
// Add attaches tasks to the runner. A task is a function that
4343
// takes an int ID.
44-
func (r *runner) Add(tasks ...func(int)) {
44+
func (r *Runner) Add(tasks ...func(int)) {
4545
r.tasks = append(r.tasks, tasks...)
4646
}
4747

4848
// Start runs all tasks and monitors channel events.
49-
func (r *runner) Start() {
49+
func (r *Runner) Start() {
5050
// We want to receive all interrupt based signals.
5151
signal.Notify(r.interrupt, os.Interrupt)
5252

@@ -74,7 +74,7 @@ func (r *runner) Start() {
7474
}
7575

7676
// run executes each registered task.
77-
func (r *runner) run() error {
77+
func (r *Runner) run() error {
7878
for id, task := range r.tasks {
7979
// Check for an interrupt signal from the OS.
8080
if r.gotInterrupt() {
@@ -89,7 +89,7 @@ func (r *runner) run() error {
8989
}
9090

9191
// gotInterrupt verifies if the interrupt signal has been issued.
92-
func (r *runner) gotInterrupt() bool {
92+
func (r *Runner) gotInterrupt() bool {
9393
select {
9494
// Signaled when an interrupt event is sent.
9595
case <-r.interrupt:

0 commit comments

Comments
 (0)