In Go, Workflow Definition code cannot directly do the following:
- Iterate over maps using
range, because with
rangethe order of the map's iteration is randomized. Instead you can collect the keys of the map, sort them, and then iterate over the sorted keys to access the map. This technique provides deterministic results. You can also use a Side Effect or an Activity to process the map instead.
- Call an external API, conduct a file I/O operation, talk to another service, etc. (Use an Activity for these.)
The Temporal Go SDK has APIs to handle equivalent Go constructs:
workflow.Now()This is a replacement for
workflow.Sleep()This is a replacement for
workflow.GetLogger()This ensures that the provided logger does not duplicate logs during a replay.
workflow.Go()This is a replacement for the
workflow.ChannelThis is a replacement for the native
chantype. Temporal provides support for both buffered and unbuffered channels.
workflow.SelectorThis is a replacement for the
selectstatement. Learn more on the Go SDK Selectors page
workflow.ContextThis is a replacement for
context.Context. Learn more on the Go SDK Context Propagation page.