hey folks, here’s my sample code. the activity, executeOperation is supposed to return a non-nil pointer to a struct and an error. however, when i run this line, futures[i].Get(ctx, &res)
, i noticed that the activity returns nil
. i’m pretty sure executeOperation is returning non-nil, error
though
i’m using go 1.23.7
type MyStruct struct {
example string
}
func executeOperation(ctx context.Context, op *MyStruct) (*MyStruct, error) {
op.example = "hi"
return op, errors.New("test")
}
func MyWorkflow(ctx workflow.Context) ([]*MyStruct, error) {
opts := workflow.ActivityOptions{
StartToCloseTimeout: time.Second * 5,
RetryPolicy: &temporal.RetryPolicy{
InitialInterval: 1 * time.Second,
MaximumAttempts: 2,
BackoffCoefficient: 1.1,
},
}
ctx = workflow.WithActivityOptions(ctx, opts)
ops := []*MyStruct{{"test1"}, {"test2"}}
futures := make([]workflow.Future, len(ops))
for i, op := range ops {
future := workflow.ExecuteActivity(ctx, executeOperation, op)
futures[i] = future
}
results := make([]*MyStruct, len(ops))
for i := 0; i < len(futures); i++ {
var res *MyStruct
if e := futures[i].Get(ctx, &res); e != nil {
// do something
}
results[i] = res
}
return results, nil
}