Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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 <T>(string grainType, GrainReference grainReference, IGrainState <T> grainState)
        {
            IStorageFaultGrain faultGrain = grainFactory.GetGrain <IStorageFaultGrain>(grainType);

            try
            {
                await InsertDelay();

                await faultGrain.OnWrite(grainReference);
            }
            catch (Exception)
            {
                logger.LogInformation(
                    "Fault injected for WriteState for grain {GrainId} of type {GrainType}",
                    grainReference.GrainId,
                    grainType);
                throw;
            }
            logger.LogInformation(
                "WriteState for grain {GrainId} of type {GrainType}",
                grainReference.GrainId,
                grainType);
            await realStorageProvider.WriteStateAsync(grainType, grainReference, grainState);
        }