"Does cadence have a concept of ""workflow evolution""?
In other words, I have a ""stateful actor"" that models a customer. Initially, the customer has two fields with some signal methods that modify them, some query methods that fetch state, and some main workflow on that actor. Suppose I have 10 of these instances and they are long-lived.
Later I want to add a third field and maybe another signal method. What can I use?
Versioning with Cadence can help here. Here's the documentation.
From the documentation, as an example, a line like below
err := workflow.ExecuteActivity(ctx, ActivityA, data).Get(ctx, &result1)
becomes
var err error
v := workflow.GetVersion(ctx, "Step1", workflow.DefaultVersion, 1)
if v == workflow.DefaultVersion {
err = workflow.ExecuteActivity(ctx, ActivityA, data).Get(ctx, &result1)
} else {
err = workflow.ExecuteActivity(ctx, ActivityC, data).Get(ctx, &result1)
}
if you have more than 2 versions it will look like below:
v := workflow.GetVersion(ctx, "Step1", workflow.DefaultVersion, 2)
if v == workflow.DefaultVersion {
err = workflow.ExecuteActivity(ctx, ActivityA, data).Get(ctx, &result1)
} else if v == 1 {
err = workflow.ExecuteActivity(ctx, ActivityC, data).Get(ctx, &result1)
} else {
err = workflow.ExecuteActivity(ctx, ActivityD, data).Get(ctx, &result1)
}
and so on. You can refer to the documentation for more details.