public virtual Task WriteStateAsync(string grainType, GrainReference grainReference, GrainState grainState) { Log.Info(0, "WriteStateAsync for {0} {1}", grainType, grainReference); Interlocked.Increment(ref writeCount); lock (StateStore) { var storedState = grainState.AsDictionary(); // Store current state data StateStore.WriteRow(MakeGrainStateKeys(grainType, grainReference), storedState, grainState.Etag); LastId = GetId(grainReference); LastState = storedState; } return(TaskDone.Done); }
public virtual Task WriteStateAsync(string grainType, GrainReference grainReference, IGrainState grainState) { logger.Info(0, "WriteStateAsync for {0} {1}", grainType, grainReference); Interlocked.Increment(ref writeCount); lock (StateStore) { var storedState = this.serializationManager.DeepCopy(grainState.State); // Store current state data var stateStore = new Dictionary <string, object> { { stateStoreKey, storedState } }; StateStore.WriteRow(MakeGrainStateKeys(grainType, grainReference), stateStore, grainState.ETag); LastId = GetId(grainReference); LastState = storedState; } return(Task.CompletedTask); }
public virtual Task WriteStateAsync <T>(string grainType, GrainReference grainReference, IGrainState <T> grainState) { logger.LogInformation("WriteStateAsync for {GrainType} {GrainId}", grainType, grainReference?.GrainId); Interlocked.Increment(ref writeCount); lock (StateStore) { var storedState = this.copier.Copy(grainState.State); // Store current state data var stateStore = new Dictionary <string, object> { { stateStoreKey, storedState } }; StateStore.WriteRow(MakeGrainStateKeys(grainType, grainReference), stateStore, grainState.ETag); LastId = GetId(grainReference); LastState = storedState; grainState.RecordExists = true; } return(Task.CompletedTask); }