コード例 #1
0
        /// <summary>
        /// Adds the Activity Grain outgoing filter.
        /// </summary>
        /// <param name="builder">The <see cref="IClientBuilder"/>.</param>
        /// <returns>The <see cref="IClientBuilder"/>.</returns>
        public static IClientBuilder AddActivityOutgoingFilter([NotNull] this IClientBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            return(builder.AddOutgoingGrainCallFilter <ActivityOutgoingGrainCallFilter>());
        }
コード例 #2
0
        /// <summary>
        /// Adds Request Context Grain call filter.
        /// </summary>
        /// <param name="builder">The <see cref="IClientBuilder"/>.</param>
        /// <param name="serviceProvider">The <see cref="IServiceProvider"/>.</param>
        /// <returns>The <see cref="IClientBuilder"/>.</returns>
        public static IClientBuilder AddRequestContextOutgoingFilter([NotNull] this IClientBuilder builder, [NotNull] IServiceProvider serviceProvider)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            builder.ConfigureServices(services => services.TryAddSingleton(serviceProvider.GetRequiredService <IRequestContextAccessor>()));

            return(builder.AddOutgoingGrainCallFilter <RequestContextGrainCallFilter>());
        }
コード例 #3
0
                public void Configure(IConfiguration configuration, IClientBuilder clientBuilder)
                {
                    clientBuilder.AddOutgoingGrainCallFilter(async ctx =>
                    {
                        if (ctx.Method?.DeclaringType == typeof(IOutgoingMethodInterceptionGrain))
                        {
                            ctx.Arguments[1] = ((string)ctx.Arguments[1]).ToUpperInvariant();
                        }

                        await ctx.Invoke();

                        if (ctx.Method?.DeclaringType == typeof(IOutgoingMethodInterceptionGrain))
                        {
                            var result       = (Dictionary <string, object>)ctx.Result;
                            result["orig"]   = result["result"];
                            result["result"] = "intercepted!";
                        }
                    });
                }
コード例 #4
0
                public void Configure(IConfiguration configuration, IClientBuilder clientBuilder)
                {
                    clientBuilder
                    .AddOutgoingGrainCallFilter(RetryCertainCalls)
                    .AddOutgoingGrainCallFilter(async ctx =>
                    {
                        if (ctx.InterfaceMethod?.DeclaringType == typeof(IOutgoingMethodInterceptionGrain) &&
                            ctx.InterfaceMethod?.Name == nameof(IOutgoingMethodInterceptionGrain.EchoViaOtherGrain))
                        {
                            ctx.Arguments[1] = ((string)ctx.Arguments[1]).ToUpperInvariant();
                        }

                        await ctx.Invoke();

                        if (ctx.InterfaceMethod?.DeclaringType == typeof(IOutgoingMethodInterceptionGrain) &&
                            ctx.InterfaceMethod?.Name == nameof(IOutgoingMethodInterceptionGrain.EchoViaOtherGrain))
                        {
                            var result       = (Dictionary <string, object>)ctx.Result;
                            result["orig"]   = result["result"];
                            result["result"] = "intercepted!";
                        }
                    })
                    .AddSimpleMessageStreamProvider("SMSProvider");