Implementing actor supervision with temporal

i’m wondering if there are any best practices on using long-running workflows as actors.

this simple case seems straightforward - signals and queries are inputs and outputs, the workflow method is the state machine loop, and it will continue-as-new when the history gets too long.

i’m also thinking of a slightly more advanced case: an actor that spawns additional actors. naively, this seems like it could be done with child workflows, but it is unclear from the documentation (and java SDK) how this would interact with continue-as-new.

  • will a child workflow’s parent close policy be invoked if the parent does a continue-as-new?
  • rather than child workflows, instead should there be an activity that spawns an independent workflow, and the workflow IDs for any running “children” be passed to the next execution in continue-is-new?

any advice is appreciated, thanks!

For first question yes, when workflow continuesaanew its completed so parent close policy applies.

Yes would start workflows from activity as you mention. Can you give more info on last part?

Also see Best way to create an async child workflow - #2 by maxim

The sliding window batch example might give some hints as well.

those links help a lot, thanks @maxim

the bit you had a question on @tihomir is the same thing that the sliding window workflow calls out as an assumption:

The assumption is that the parent workflow doesn’t need to deal with child workflow results and failures.

i’m not concerned with child workflow results, but i do want to have the parent deal with child workflow failures.

that’s where i was thinking about passing the set of active child workflow IDs through continueAsNew so the “new parent” can continue to keep track of them.

conceptually, i’m trying to build an Erland-like supervision structure, https://www.erlang.org/doc/design_principles/sup_princ.html

Unfortunately, at this point, it is not possible if you need to call continue-as-new. Here is the issue to allow listening for a result of an external workflow.

thanks for the info @maxim ! i think i have a good understanding of what’s possible today.