コード例 #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 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 faultGrain.OnRead(grainReference);
            }
            catch (Exception)
            {
                Log.Info($"Fault injected for ReadState for grain {grainReference} of type {grainType}, ");
                throw;
            }
            Log.Info($"ReadState for grain {grainReference} of type {grainType}");
            await realStorageProvider.ReadStateAsync(grainType, grainReference, grainState);
        }
コード例 #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 populated for this grain.</param>
        /// <returns>Completion promise for the Read operation on the specified grain.</returns>
        public async Task ReadStateAsync <T>(string grainType, GrainReference grainReference, IGrainState <T> grainState)
        {
            IStorageFaultGrain faultGrain = grainFactory.GetGrain <IStorageFaultGrain>(grainType);

            try
            {
                await InsertDelay();

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