Skip to content

Conversation

@ReubenBond
Copy link
Member

@ReubenBond ReubenBond commented Apr 2, 2025

  • IGrainState<T>.State should always be created using Activator.CreateInstance<T>().
  • IGrainState<T>.State should never be null after returning from an IGrainStorage method without an exception being thrown. That means it should be set to a new instance of T in ReadStateAsync() and ClearStateAsync() before returning if it would otherwise have been null.
  • IGrainState<T>.RecordExists should be true if the application has had the chance to initialize state since creation or the last time the state was reset. It should be false if the state is not present in the database or the record has no contents, and true otherwise. The purpose is to give application developers a chance to initialize state to a valid value during activation and after clearing state.
  • IGrainState<T>.ETag should be null if storage system contains a record for the grain state, and non-null otherwise.

Fixes #7780
Fixes #9093
Fixes #3516
Fixes #9198

Microsoft Reviewers: Open in CodeFlow

@ReubenBond ReubenBond force-pushed the fix/storage-provider-behaviors branch 3 times, most recently from de48ae9 to 7c8b987 Compare April 2, 2025 23:29
@ReubenBond ReubenBond changed the title Align grain storage provider behavior. Align behavior of grain storage providers when setting IGrainState<T> properties Apr 2, 2025
@ReubenBond ReubenBond force-pushed the fix/storage-provider-behaviors branch from 78b825f to 78df950 Compare April 4, 2025 00:14
ReubenBond added a commit to ReubenBond/orleans that referenced this pull request Apr 4, 2025
@ReubenBond ReubenBond merged commit 34d9f1c into dotnet:main Apr 4, 2025
24 of 25 checks passed
@ReubenBond ReubenBond deleted the fix/storage-provider-behaviors branch April 4, 2025 18:26
@github-actions github-actions bot locked and limited conversation to collaborators May 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.