workflows.SubmitSubtasks(
ctx context.Context,
tasks []workflows.Task,
options ...subtask.SubmitOption,
) ([]subtask.FutureTask, error)
Submit multiple subtasks to the task runner. Same as SubmitSubtask, but accepts a list of tasks.
This function is intended to be used in tasks.
Parameters
A list of tasks to submit
Options
WithDependencies(dependencies ...FutureTask)
Set dependencies for the tasks
WithClusterSlug(clusterSlug string)
default:"cluster of the task runner"
Set the cluster slug of the cluster where the tasks will be executed.
WithMaxRetries(maxRetries int64)
Set the maximum number of retries for the subtasks in case it fails
Returns
A list of future tasks that can be used to set dependencies between tasks.
type MySubTask struct {
Sensor string
Value float64
}
type Task struct{}
func (t *Task) Execute(ctx context.Context) error {
err := workflows.SubmitSubtasks(ctx,
[]workflows.Task{
&MySubTask{
Sensor: "A",
Value: 42,
},
&MySubTask{
Sensor: "B",
Value: 42,
}
},
)
if err != nil {
return fmt.Errorf("failed to submit subtasks: %w", err)
}
return nil
}