Is It Possible To Separate Activity/Child WF From Main WF?

I have a use case where individual activity/child workflow is a microservice. I don’t want the code of microservice accessible to others. Thus, the users shall be able to call individual microservice by some refrence and it shall be treated as treated as blackbox to others. What are the possible way of dealing with these?

Hi @kumar.ashish

you can invoke workflows/child workflows and activities by their type name, for workflows see docs here where the workflow type “MySimpleWorkflow” is used to start workflow execution. You can do similar with activities, for example:

err := workflow.ExecuteActivity(ctx, "MyActivity", name).Get(ctx, &result)

where “MyActivity” is the name of your activity function.
You can document your workflows/activities/signal/query names for your end users (maybe like for example swagger docs) rather than sharing the impls and they will be able to interact with your services via Temporal sdk apis. You would need to also share the namespace and task queue names where your workers that host these workflows/activities are polling on.

Note that if your end users are writing workflows where they want to invoke your activities by name you cannot currently specify a different namespace in ActivityOptions (will inherit that of the workflow), so their workflows would need to run in the same namespace as your activity workers. This shouldn’t be an issue with workflows/child workflows.

1 Like

Thank you @tihomir , much appreciated help. Will definitely try that