Using Go SDK I’m trying to register a workflow definition which is implemented inside a type’s method but when I try to run it it fails with the following error:
"msg": "Failed to process workflow task.",
"Error": "unable to find workflow type: func1. Supported types: [MyWorkflowDef]"
This is what I do (partial code to fit question):
type MyType[T any] struct {
Data T
}
func (lw *MyType[T]) MyWorkflowDef(wfctx workflow.Context) error {
fmt.Println(lw.Data)
return nil
}
var myWorkflow MyType[string] = MyType[string]{Data: "hello temporal"}
func codeThatRunsInGoroutine() {
w := worker.New(client, workflowsTaskQueue, worker.Options{MaxConcurrentActivityExecutionSize:1})
w.RegisterWorkflow(myWorkflow.MyWorkflowDef)
w.Run(nil)
}
func TryingToRunWorkflow(ctx context.Context) {
client.SignalWithStartWorkflow(ctx, "My Workflow", "My Signal", signal, workflowOptions, myWorkflow.MyWorkflowDef)
}