|
| 1 | +package activity |
| 2 | + |
| 3 | +import "context" |
| 4 | + |
| 5 | +// GlobalActivityOutputs maps each action name to a list of its result maps. |
| 6 | +// {"noop.log": [{"logged": "hello"}, {"logged": "world"}], "noop.echo": [...]} |
| 7 | +type GlobalActivityOutputs map[string][]map[string]interface{} |
| 8 | + |
| 9 | +// ActivityInput is the generic input passed to all activities. |
| 10 | +type ActivityInput struct { |
| 11 | + Action string `json:"action"` |
| 12 | + Params map[string]interface{} `json:"params"` |
| 13 | + StepName string `json:"step_name"` |
| 14 | + WorkflowExecutionId string `json:"workflow_execution_id"` |
| 15 | + Async bool `json:"async"` |
| 16 | + PluginVersion string `json:"plugin_version"` |
| 17 | + StepId string `json:"step_id,omitempty"` |
| 18 | + // Attempt is the 1-based Temporal activity attempt number for this invocation. |
| 19 | + // Async plugins must include this in the payload they send to the external system |
| 20 | + // so that callbacks can be routed back to the exact attempt that triggered the work. |
| 21 | + Attempt int `json:"attempt,omitempty"` |
| 22 | + // Config holds plugin-specific configuration injected from etcd at call time. |
| 23 | + // Plugins should read environment-specific values from here instead of os.Getenv, |
| 24 | + // so that config can be updated in etcd without redeploying the orchestrator. |
| 25 | + Config map[string]string `json:"config,omitempty"` |
| 26 | +} |
| 27 | + |
| 28 | +// ActivityOutput is the generic output returned by all activities. |
| 29 | +type ActivityOutput struct { |
| 30 | + Result map[string]interface{} `json:"result,omitempty"` |
| 31 | + Error string `json:"error,omitempty"` |
| 32 | +} |
| 33 | + |
| 34 | +// ActivityFunc is the function signature that every registered activity must implement. |
| 35 | +type ActivityFunc func(ctx context.Context, globalOutputs GlobalActivityOutputs, input ActivityInput) (ActivityOutput, error) |
0 commit comments