/// <summary>Faults if exception is provided, otherwise calls through to decorated storage provider.</summary> /// <param name="grainType">Type of this grain [fully qualified class name]</param> /// <param name="grainReference">Grain reference object for this grain.</param> /// <param name="grainState">Copy of last-known state data object for this grain.</param> /// <returns>Completion promise for the Delete operation on the specified grain.</returns> public async Task ClearStateAsync <T>(string grainType, GrainReference grainReference, IGrainState <T> grainState) { IStorageFaultGrain faultGrain = grainFactory.GetGrain <IStorageFaultGrain>(grainType); try { await InsertDelay(); await faultGrain.OnClear(grainReference); } catch (Exception) { logger.LogInformation( "Fault injected for ClearState for grain {GrainId} of type {GrainType}", grainReference.GrainId, grainType); throw; } logger.LogInformation( "ClearState for grain {GrainId} of type {GrainType}", grainReference.GrainId, grainType); await realStorageProvider.ClearStateAsync(grainType, grainReference, grainState); }
/// <summary>Faults if exception is provided, otherwise calls through to decorated storage provider.</summary> /// <param name="grainType">Type of this grain [fully qualified class name]</param> /// <param name="grainReference">Grain reference object for this grain.</param> /// <param name="grainState">State data object to be written for this grain.</param> /// <returns>Completion promise for the Write operation on the specified grain.</returns> public async Task WriteStateAsync(string grainType, GrainReference grainReference, IGrainState grainState) { IStorageFaultGrain faultGrain = grainFactory.GetGrain <IStorageFaultGrain>(grainType); try { await faultGrain.OnWrite(grainReference); } catch (Exception) { Log.Info($"Fault injected for WriteState for grain {grainReference} of type {grainType}"); throw; } Log.Info($"WriteState for grain {grainReference} of type {grainType}"); await realStorageProvider.WriteStateAsync(grainType, grainReference, grainState); }
/// <summary>Faults if exception is provided, otherwise calls through to decorated storage provider.</summary> /// <param name="grainType">Type of this grain [fully qualified class name]</param> /// <param name="grainReference">Grain reference object for this grain.</param> /// <param name="grainState">State data object to be populated for this grain.</param> /// <returns>Completion promise for the Read operation on the specified grain.</returns> public async Task ReadStateAsync(string grainType, GrainReference grainReference, IGrainState grainState) { IStorageFaultGrain faultGrain = grainFactory.GetGrain <IStorageFaultGrain>(grainType); try { await InsertDelay(); await faultGrain.OnRead(grainReference); } catch (Exception) { logger.Info($"Fault injected for ReadState for grain {grainReference} of type {grainType}, "); throw; } logger.Info($"ReadState for grain {grainReference} of type {grainType}"); await realStorageProvider.ReadStateAsync(grainType, grainReference, grainState); }