forked from mostafa-asg/dag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdsl.go
59 lines (49 loc) · 948 Bytes
/
dsl.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package dag
type pipelineResult struct {
dag *Dag
}
func (result *pipelineResult) Then() *pipelineDSL {
return &pipelineDSL{
result.dag,
}
}
func (result *pipelineResult) OnComplete(action func()) *pipelineResult {
job := result.dag.lastJob()
if job != nil {
job.onComplete = action
}
return result
}
type pipelineDSL struct {
dag *Dag
}
func (dsl *pipelineDSL) Spawns(tasks ...func()) *spawnsResult {
dsl.dag.Spawns(tasks...)
return &spawnsResult{
dsl.dag,
}
}
type spawnsResult struct {
dag *Dag
}
func (result *spawnsResult) Join() *spawnsDSL {
return &spawnsDSL{
result.dag,
}
}
func (result *spawnsResult) OnComplete(action func()) *spawnsResult {
job := result.dag.lastJob()
if job != nil {
job.onComplete = action
}
return result
}
type spawnsDSL struct {
dag *Dag
}
func (dsl *spawnsDSL) Pipeline(tasks ...func()) *pipelineResult {
dsl.dag.Pipeline(tasks...)
return &pipelineResult{
dsl.dag,
}
}