Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new instance of <see cref="Grpc.Core.Interceptors.InterceptingCallInvoker" />
 /// with the given underlying invoker and interceptor instances.
 /// </summary>
 public InterceptingCallInvoker(CallInvoker invoker, Interceptor interceptor)
 {
     this.invoker     = GrpcPreconditions.CheckNotNull(invoker, nameof(invoker));
     this.interceptor = GrpcPreconditions.CheckNotNull(interceptor, nameof(interceptor));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns a <see cref="Grpc.Core.CallInvoker" /> instance that intercepts
 /// the channel with the given interceptor.
 /// </summary>
 /// <param name="channel">The channel to intercept.</param>
 /// <param name="interceptor">The interceptor to intercept the channel with.</param>
 /// <remarks>
 /// Multiple interceptors can be added on top of each other by calling
 /// "channel.Intercept(a, b, c)".  The order of invocation will be "a", "b", and then "c".
 /// Interceptors can be later added to an existing intercepted channel, effectively
 /// building a chain like "channel.Intercept(c).Intercept(b).Intercept(a)".  Note that
 /// in this case, the last interceptor added will be the first to take control.
 /// </remarks>
 public static CallInvoker Intercept(this Channel channel, Interceptor interceptor)
 {
     return(new DefaultCallInvoker(channel).Intercept(interceptor));
 }
 public InterceptingServiceBinder(Interceptor interceptor)
 {
     this.interceptor = GrpcPreconditions.CheckNotNull(interceptor, nameof(interceptor));
 }
        /// <summary>
        /// Returns a <see cref="Grpc.Core.ServerServiceDefinition" /> instance that
        /// intercepts incoming calls to the underlying service handler through the given interceptor.
        /// </summary>
        /// <param name="serverServiceDefinition">The <see cref="Grpc.Core.ServerServiceDefinition" /> instance to register interceptors on.</param>
        /// <param name="interceptor">The interceptor to intercept the incoming invocations with.</param>
        /// <remarks>
        /// Multiple interceptors can be added on top of each other by calling
        /// "serverServiceDefinition.Intercept(a, b, c)".  The order of invocation will be "a", "b", and then "c".
        /// Interceptors can be later added to an existing intercepted service definition, effectively
        /// building a chain like "serverServiceDefinition.Intercept(c).Intercept(b).Intercept(a)".  Note that
        /// in this case, the last interceptor added will be the first to take control.
        /// </remarks>
        public static ServerServiceDefinition Intercept(this ServerServiceDefinition serverServiceDefinition, Interceptor interceptor)
        {
            GrpcPreconditions.CheckNotNull(serverServiceDefinition, nameof(serverServiceDefinition));
            GrpcPreconditions.CheckNotNull(interceptor, nameof(interceptor));

            var binder = new InterceptingServiceBinder(interceptor);

            serverServiceDefinition.BindService(binder);
            return(binder.GetInterceptedServerServiceDefinition());
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Returns a <see cref="Grpc.Core.ServerServiceDefinition" /> instance that
 /// intercepts incoming calls to the underlying service handler through the given interceptor.
 /// </summary>
 /// <param name="serverServiceDefinition">The <see cref="Grpc.Core.ServerServiceDefinition" /> instance to register interceptors on.</param>
 /// <param name="interceptor">The interceptor to intercept the incoming invocations with.</param>
 /// <remarks>
 /// Multiple interceptors can be added on top of each other by calling
 /// "serverServiceDefinition.Intercept(a, b, c)".  The order of invocation will be "a", "b", and then "c".
 /// Interceptors can be later added to an existing intercepted service definition, effectively
 /// building a chain like "serverServiceDefinition.Intercept(c).Intercept(b).Intercept(a)".  Note that
 /// in this case, the last interceptor added will be the first to take control.
 /// </remarks>
 public static ServerServiceDefinition Intercept(this ServerServiceDefinition serverServiceDefinition, Interceptor interceptor)
 {
     GrpcPreconditions.CheckNotNull(serverServiceDefinition, nameof(serverServiceDefinition));
     GrpcPreconditions.CheckNotNull(interceptor, nameof(interceptor));
     return(new ServerServiceDefinition(serverServiceDefinition.CallHandlers.ToDictionary(x => x.Key, x => x.Value.Intercept(interceptor))));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Returns a <see cref="Grpc.Core.CallInvoker" /> instance that intercepts
 /// the invoker with the given interceptor.
 /// </summary>
 /// <param name="invoker">The underlying invoker to intercept.</param>
 /// <param name="interceptor">The interceptor to intercept calls to the invoker with.</param>
 /// <remarks>
 /// Multiple interceptors can be added on top of each other by calling
 /// "invoker.Intercept(a, b, c)".  The order of invocation will be "a", "b", and then "c".
 /// Interceptors can be later added to an existing intercepted CallInvoker, effectively
 /// building a chain like "invoker.Intercept(c).Intercept(b).Intercept(a)".  Note that
 /// in this case, the last interceptor added will be the first to take control.
 /// </remarks>
 public static CallInvoker Intercept(this CallInvoker invoker, Interceptor interceptor)
 {
     return(new InterceptingCallInvoker(invoker, interceptor));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Returns a <see cref="Grpc.Core.CallInvoker" /> instance that intercepts
 /// the channel with the given interceptor.
 /// </summary>
 /// <param name="channel">The channel to intercept.</param>
 /// <param name="interceptor">The interceptor to intercept the channel with.</param>
 /// <remarks>
 /// Multiple interceptors can be added on top of each other by calling
 /// "channel.Intercept(a, b, c)".  The order of invocation will be "a", "b", and then "c".
 /// Interceptors can be later added to an existing intercepted channel, effectively
 /// building a chain like "channel.Intercept(c).Intercept(b).Intercept(a)".  Note that
 /// in this case, the last interceptor added will be the first to take control.
 /// </remarks>
 public static CallInvoker Intercept(this ChannelBase channel, Interceptor interceptor)
 {
     return(channel.CreateCallInvoker().Intercept(interceptor));
 }