-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathparallel.go
More file actions
57 lines (53 loc) · 1.54 KB
/
parallel.go
File metadata and controls
57 lines (53 loc) · 1.54 KB
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
package builder
import (
"github.com/flowexec/flow/types/executable"
)
func ParallelExecByRefConfig(opts ...Option) *executable.Executable {
name := "parallel-config"
e1 := SimpleExec(opts...)
e2 := ExecWithArgs(opts...)
e := &executable.Executable{
Verb: "start",
Name: name,
Visibility: privateExecVisibility(),
Parallel: &executable.ParallelExecutableType{
Execs: []executable.ParallelRefConfig{
{Ref: e1.Ref()},
{Ref: e2.Ref(), Args: []string{"hello", "x=123"}},
{Cmd: "echo 'hello from serial command'"},
},
},
}
if len(opts) > 0 {
vals := NewOptionValues(opts...)
e.SetContext(vals.WorkspaceName, vals.WorkspacePath, vals.NamespaceName, vals.FlowFilePath)
}
return e
}
func ParallelExecWithExit(opts ...Option) *executable.Executable {
name := "parallel-with-failure"
e1 := ExecWithPauses(opts...)
e2 := ExecWithExit(opts...)
e3 := ExecWithPauses(opts...)
ff := true
e := &executable.Executable{
Verb: "start",
Name: name,
Aliases: []string{"parallel-exit"},
Visibility: privateExecVisibility(),
Parallel: &executable.ParallelExecutableType{
FailFast: &ff,
Execs: executable.ParallelRefConfigList{{Ref: e1.Ref()}, {Ref: e2.Ref()}, {Ref: e3.Ref()}},
},
}
if len(opts) > 0 {
vals := NewOptionValues(opts...)
e.SetContext(vals.WorkspaceName, vals.WorkspacePath, vals.NamespaceName, vals.FlowFilePath)
}
return e
}
func ParallelExecWithMaxThreads(opts ...Option) *executable.Executable {
e := ParallelExecByRefConfig(opts...)
e.Parallel.MaxThreads = 1
return e
}