Skip to content

DurableTask.GetVersion(string, int, int)

GetVersion(string, int, int)

static
View source
public static int GetVersion(string name, int minSupported, int maxSupported)
Returns the version of the change name which the running durable task follows, so code which changes a workflow keeps replaying the executions which started before the change.

Parameters

namestring
The change's name within the running task, such as "carrier-api". Every call with the same name in one execution returns the same version. Names don't contain $.
minSupportedint
The oldest version which the calling code still supports. Version 0 is the code before the change's first version.
maxSupportedint
The newest version, which executions that reach the call for the first time record.

Returns

A version from minSupported to maxSupported.

Exceptions

System.ArgumentNullException
name is null.
System.ArgumentException
name is empty or contains $.
System.ArgumentOutOfRangeException
minSupported is negative, or maxSupported is less than minSupported.
Orleans.Durable.Tasks.DurableTaskAttemptCanceledException
The host canceled the attempt, for example because the execution recorded a version outside the supported range, which stalls it; the exception's inner exception is then a DurableTaskVersionException.
System.InvalidOperationException
The host can't record the version from the calling code, for example after ConfigureAwait(false).
System.NotSupportedException
The host doesn't support versions.

Examples

var version = DurableTask.GetVersion("carrier-api", minSupported: 0, maxSupported: 1);
if (version >= 1)
{
await carrier.BookAsync(order).WithId("book");
}
else
{
await legacyShipping.ShipAsync(order).WithId("ship");
}