Microservice Communication. Replace REST APIs with Child Workflow Executions. Project structure

Hi everybody,

I am new to Temporal and would greatly appreciate your help with structuring my application:


HAVE

3 microservices that communicate over REST APIs:

  • SERVICE_A (TypeScript) has three workflows: WA_1, WA_2, WA_3.
  • SERVICE_B (Go) has three workflows: WB_1, WB_2, WB_3.
  • SERVICE_C (Python) has three workflows: WC_1, WC_2, WC_3.

Service workflows should be able to call each other as child workflows.
For example, WA_1 should be able to start WA_3 or WB_2 or WC_1 as a child workflow.


WANT

to get rid of the REST APIs and rewrite the three microservices as Temporal workflows, where the former API routes would translate into workflow definitions/activities.


QUESTIONS

  1. Is it possible to start child workflows by WorkflowType:string in all three languages (TypeScript, Go, Python)?
  2. Could you please outline a rough project structure considering that some activities might be shared between workflows and languages?
  3. Is it possible (does it make sense?) to write all the workflows (WA_1, WA_2, WA_3, WB_1, WB_2, WB_3, WC_1, WC_2, WC_3) in one language (for example, TypeScript) and reuse the existing REST API code (TypeScript, Python and Go) as activities?

Thank you!
P.S. I have just started using Temporal and it is beautiful! Thank you TEAM for open-sourcing it :heart:

  1. Is it possible to start child workflows by WorkflowType:string in all three languages (TypeScript, Go, Python)?

Yes this is perfectly possible. You would also need to know the task queue name (string) where you need to route this execution to. Note that if you call this as a child workflow it should be on the same namespace currently. We have a Nexus project thats under development that will make x-namespace child workflow invocations possible.

  1. Could you please outline a rough project structure considering that some activities might be shared between workflows and languages?

Similarly to workflows/child workflows you can also invoke activities by their activity type (string), also need to specify the task queue. They don’t have to run on your workflow workers.

  1. Is it possible (does it make sense?) to write all the workflows (WA_1, WA_2, WA_3, WB_1, WB_2, WB_3, WC_1, WC_2, WC_3) in one language (for example, TypeScript) and reuse the existing REST API code (TypeScript, Python and Go) as activities?

Workflows and activities in language X have to be executed on workers that are also using language X.
For activities that are reused between services, would consider having them on a separate task queue (and thus separate set of activity workers) as then you can scale them better as you add more services that use them as well as be able to set task queue rate limits for them across all microservices that use them if needed.

thanks @tihomir for the rocket-fast reply!