Automatic ContinueAsNew

Hello!

We want to provide our clients to write playbooks with DSL that then will be run on temporal. We don’t know in advance how big those workflow will be in the result and we expect that some of them could exceed workflow history size or count limits. Is there any recommended way how to automatically make such workflows ContinueAsNew? for example watching some metrics or analyzing events, etc.

Thanks in advance.

1 Like

Currently there is no way to access the history size or count, but we will add it soon, see Workflow API to check if ContinueAsNew is required · Issue #628 · temporalio/sdk-go · GitHub.

In the meantime, many people keep their own counters and just continue as new based on what they consider an appropriate count of things they did and testing. For example, you could keep a counter for each signal received and activity executed and begin the continue as new process when it reaches, say, 1000 (or any other number, would want to test to see how it translates to your sizes).

I say “begin the continue as new process” because if you don’t want to lose signals or activity results, you need to drain all signal channels and wait for all futures before continuing as new.