-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexec.go
More file actions
31 lines (26 loc) · 674 Bytes
/
exec.go
File metadata and controls
31 lines (26 loc) · 674 Bytes
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
package framework
import "context"
type ExecutionContext struct {
topology *Topology
stages map[StageName]*Semaphore
err *AggregatedError
}
func NewExecutionContext(ctx context.Context, topology *Topology, ae *AggregatedError) *ExecutionContext {
return &ExecutionContext{
topology: topology,
stages: map[StageName]*Semaphore{
StagePrepare: NewSemaphore(),
StageStart: NewSemaphore(),
StageWait: NewSemaphore(),
StageCleanup: NewSemaphore(),
},
err: ae,
}
}
func (c *ExecutionContext) Wait() error {
c.AwaitStage(StageCleanup)
return c.err.Join()
}
func (c *ExecutionContext) AwaitStage(name StageName) {
c.stages[name].Wait()
}