sdk-go icon indicating copy to clipboard operation
sdk-go copied to clipboard

Support dynamic activity and workflow implementations

Open aschrijver opened this issue 4 years ago • 8 comments

Is your feature request related to a problem? Please describe. In some cases, activity and workflow implementations should be loaded dynamically.

Describe the solution you'd like Expose an extension point for dynamic activity loading. This issue is created to ensure feature parity among SDK's where https://github.com/temporalio/sdk-java/issues/245 already implements this for Java.

Additional context In Dynamic activities registration at runtime and worker splitting on the community forum @mfateev requested another user to create this issue, but that never happened AFAIK. Hence this issue.

aschrijver avatar Sep 21 '21 07:09 aschrijver

Hi, is there some progress?

zhyg avatar Apr 27 '22 03:04 zhyg

We have not prioritized this because there haven't been many requests. Are you needing dynamic activity/workflow support? In almost all cases, a properly named/registered activity/workflow should be used and field in the parameter can be provided to take different paths. Can you describe your use case (here or in Slack or in forum)?

cretz avatar Apr 27 '22 13:04 cretz

@cretz can you share an example of what you describe ?

nb950 avatar May 23 '22 00:05 nb950

Something like:

func FallthroughWorkflow(ctx workflow.Context) error {
  workflow.GetLogger(ctx).Info("Called workflow: " + workflow.GetInfo(ctx).WorkflowType.Name)
}

func FallthroughActivity(ctx context.Context) error {
  activity.GetLogger(ctx).Info("Called activity: " + activity.GetInfo(ctx).ActivityType.Name)
}

func Register(worker worker.Worker) error {
  worker.RegisterWorkflowWithOptions(FallthroughWorkflow, workflow.RegisterOptions{Dynamic: true})
  worker.RegisterActivityWithOptions(FallthroughActivity, activity.RegisterOptions{Dynamic: true})
}

So basically that workflow or activity is called when one for the specific name is not found.

cretz avatar May 23 '22 14:05 cretz

Hi,

We are also looking at support for dynamic activity registration for Go. Would be great if you can provide some ETA?

Thanks, Jay.

k-jay-c avatar Jul 26 '22 08:07 k-jay-c

I think we need to do the workflow.RegisterOptions{Dynamic: true}/activity.RegisterOptions{Dynamic: true} and we need to require that the function signature accept a string name and a slice of converter.EncodedValue values.

cretz avatar Jan 05 '23 13:01 cretz