struct GlobalConfig {
maxChildWorkflows int64
}
var globalConfig GlobalConfig
func ConstructGlobalConfig() {
// Constructs Global config by reading from a config file.
// globalConfig.maxChildWorkflows = <some-value>
}
func main() {
ConstructGlobalConfig()
}
func FooWorkflow() {
maxChildWorkflows := globalConfig.maxChildWorkflows
for i := 0; i < maxChildWorkflows; i++ {
startChildWorkflow()
}
}
In the above example, maxChildWorkflows can change across worker crashes if the global configuration changes which can lead to non-determinstic workflow behavior. What options do I have to make sure this read in deterministic? One option that I thought of
- Create an activity which performs the read from the GlobalConfig. Another activity just to access a variable from memory seems like an overkill.
Is there a better way to remember variable in a workflow?
Note that this value can’t be a parameter to the workflow because this workflow is run as a cron job and the expectation is to keep the maxChildWorkflows as a configurable value.