-
Notifications
You must be signed in to change notification settings - Fork 1
/
engineRoot.go
43 lines (35 loc) · 997 Bytes
/
engineRoot.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package sup
import (
"context"
"path/filepath"
)
type superviseRoot struct {
// no need for the whole phase machine on this one; we never return a
// public handle to any part of this implementation.
task *boundTask
}
func (superviseRoot) Phase() Phase {
return Phase_collecting
}
func (mgr superviseRoot) init(task Supervisor) Supervisor {
mgr.task = bindTask(task)
return &mgr
}
func (mgr superviseRoot) Name() string {
return "-"
}
func (mgr *superviseRoot) Run(parentCtx context.Context) error {
return mgr.childLaunch(parentCtx, mgr.task)
}
func (mgr superviseRoot) childLaunch(groupCtx context.Context, task *boundTask) (report error) {
var childErr error
defer func() {
report = childErr
// TODO panic recovery
// also TODO this child launcher isn't *exactly* duped yet but it's close, refactor
}()
taskPath := filepath.Join(CtxTaskPath(groupCtx), task.name)
ctx := appendCtxInfo(groupCtx, ctxInfo{task, taskPath})
childErr = task.original.Run(ctx)
return
}