Understanding grain interface versioning
As the application grows over a period, there can be the addition of new actions to grains or changes to the existing implementations. To adhere to these changes, we normally version the functionality. In Orleans, versioning of grains is supported through grain interface versioning. To version a grain, we add the Version
attribute to the grain interface as shown in the following snippet:
[Version(1)] public interface IHotelGrain : IGrainWithStringKey
In the preceding code snippet, the version of IHotelGrain
is 1
. The default version of a grain interface is 0
. That means the version of a grain without a version attribute is 0
.
Grain activation with versions
The following flow chart depicts the activation of a versioned grain:
When there is a message to a versioned grain, the Orleans runtime first checks whether there is an existing activation. If there is...