An exact source excerpt. Inspect the complete file to see its imports, surrounding types, and error handling.
guest/go-module/workflow.goExcerpt begins at line 75File SHA-25660a37644d5cfc8f6f3467f2c2545e9088e4c174dc0d9192e3538b4497ed8ad73
Workflow host operations go
75type FunctionOptions struct{ DatasetTransaction string }7677func Function(name string, input Value, options ...FunctionOptions) (Value, error) {78 if len(options) > 1 {79 return Value{}, errors.New("Function accepts at most one options value")80 }81 args := map[string]Value{"input": input}82 if len(options) == 1 && options[0].DatasetTransaction != "" {83 args["dataset_transaction"] = String(options[0].DatasetTransaction)84 }85 return WorkflowCall("function", name, MustObject(args))86}87func Action(name string, input Value, target, candidateReceiptID *string) (Value, error) {88 targetValue, candidateValue := Null(), Null()89 if target != nil {90 targetValue = String(*target)91 }92 if candidateReceiptID != nil {93 candidateValue = String(*candidateReceiptID)94 }95 return WorkflowCall("action", name, MustObject(map[string]Value{96 "input": input, "target": targetValue, "candidate_receipt_id": candidateValue,97 }))98}99func StartWorkflow(name string, input Value) (Value, error) {100 return WorkflowCall("start_workflow", name, MustObject(map[string]Value{"input": input}))101}102func GetResult(runID string) (Value, error) {103 return WorkflowCall("get_result", "", MustObject(map[string]Value{"run_id": String(runID)}))104}105106// CancelChild stops one child Workflow this Run started. A structured child's107// lifetime belongs to its parent, which also stops every outstanding child when108// it settles; already committed child Actions are never compensated.
Run it in its product environment.
This source depends on its surrounding product, generated libraries, and platform runtime. The website demonstrations run locally in your browser and do not execute this source against a workspace.