Polish and address review comments

pull/12613/head
Mehrdad Afshari 7 years ago
parent 8f1eab1b29
commit 074b802c9f
  1. 6
      src/csharp/Grpc.Core/Interceptors/CallInvokerExtensions.cs
  2. 4
      src/csharp/Grpc.Core/Interceptors/ChannelExtensions.cs
  3. 12
      src/csharp/Grpc.Core/Interceptors/ClientInterceptorContext.cs
  4. 4
      src/csharp/Grpc.Core/Interceptors/InterceptingCallInvoker.cs
  5. 8
      src/csharp/Grpc.Core/Interceptors/ServerServiceDefinitionExtensions.cs
  6. 10
      src/csharp/Grpc.Core/Internal/ServerCallHandler.cs

@ -64,8 +64,8 @@ namespace Grpc.Core.Interceptors
/// </remarks> /// </remarks>
public static CallInvoker Intercept(this CallInvoker invoker, params Interceptor[] interceptors) public static CallInvoker Intercept(this CallInvoker invoker, params Interceptor[] interceptors)
{ {
GrpcPreconditions.CheckNotNull(invoker, "invoker"); GrpcPreconditions.CheckNotNull(invoker, nameof(invoker);
GrpcPreconditions.CheckNotNull(interceptors, "interceptors"); GrpcPreconditions.CheckNotNull(interceptors, nameof(interceptors));
foreach (var interceptor in interceptors.Reverse()) foreach (var interceptor in interceptors.Reverse())
{ {
@ -104,7 +104,7 @@ namespace Grpc.Core.Interceptors
/// </summary> /// </summary>
public MetadataInterceptor(Func<Metadata, Metadata> interceptor) public MetadataInterceptor(Func<Metadata, Metadata> interceptor)
{ {
this.interceptor = GrpcPreconditions.CheckNotNull(interceptor, "interceptor"); this.interceptor = GrpcPreconditions.CheckNotNull(interceptor, nameof(interceptor));
} }
protected override ClientCallHooks<TRequest, TResponse> InterceptCall<TRequest, TResponse>(ClientInterceptorContext<TRequest, TResponse> context, bool clientStreaming, bool serverStreaming, TRequest request) protected override ClientCallHooks<TRequest, TResponse> InterceptCall<TRequest, TResponse>(ClientInterceptorContext<TRequest, TResponse> context, bool clientStreaming, bool serverStreaming, TRequest request)

@ -76,9 +76,7 @@ namespace Grpc.Core.Interceptors
/// invocation metadata. /// invocation metadata.
/// </param> /// </param>
/// <remarks> /// <remarks>
/// Multiple interceptors can be added on top of each other by calling /// Multiple interceptors can be added on top of each other by
/// "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 /// 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. /// in this case, the last interceptor added will be the first to take control.
/// </remarks> /// </remarks>

@ -46,20 +46,20 @@ namespace Grpc.Core.Interceptors
} }
/// <summary> /// <summary>
/// Gets or sets the <see cref="Grpc.Core.Method{TRequest, TResponse}"/> instance /// Gets the <see cref="Grpc.Core.Method{TRequest, TResponse}"/> instance
/// representing the method to be invoked. /// representing the method to be invoked.
/// </summary> /// </summary>
public Method<TRequest, TResponse> Method { get; set; } public Method<TRequest, TResponse> Method { get; }
/// <summary> /// <summary>
/// Gets or sets the host that the currect invocation will be dispatched to. /// Gets the host that the currect invocation will be dispatched to.
/// </summary> /// </summary>
public string Host { get; set; } public string Host { get; }
/// <summary> /// <summary>
/// Gets or sets the <see cref="Grpc.Core.CallOptions"/> structure representing the /// Gets the <see cref="Grpc.Core.CallOptions"/> structure representing the
/// call options associated with the current invocation. /// call options associated with the current invocation.
/// </summary> /// </summary>
public CallOptions Options { get; set; } public CallOptions Options { get; }
} }
} }

@ -36,8 +36,8 @@ namespace Grpc.Core.Interceptors
/// </summary> /// </summary>
public InterceptingCallInvoker(CallInvoker invoker, Interceptor interceptor) public InterceptingCallInvoker(CallInvoker invoker, Interceptor interceptor)
{ {
this.invoker = GrpcPreconditions.CheckNotNull(invoker, "invoker"); this.invoker = GrpcPreconditions.CheckNotNull(invoker, nameof(invoker));
this.interceptor = GrpcPreconditions.CheckNotNull(interceptor, "interceptor"); this.interceptor = GrpcPreconditions.CheckNotNull(interceptor, nameof(interceptor));
} }
/// <summary> /// <summary>

@ -44,8 +44,8 @@ namespace Grpc.Core.Interceptors
/// </remarks> /// </remarks>
public static ServerServiceDefinition Intercept(this ServerServiceDefinition serverServiceDefinition, Interceptor interceptor) public static ServerServiceDefinition Intercept(this ServerServiceDefinition serverServiceDefinition, Interceptor interceptor)
{ {
GrpcPreconditions.CheckNotNull(serverServiceDefinition, "serverServiceDefinition"); GrpcPreconditions.CheckNotNull(serverServiceDefinition, nameof(serverServiceDefinition));
GrpcPreconditions.CheckNotNull(interceptor, "interceptor"); GrpcPreconditions.CheckNotNull(interceptor, nameof(interceptor));
return new ServerServiceDefinition(serverServiceDefinition.CallHandlers.ToDictionary(x => x.Key, x => x.Value.Intercept(interceptor))); return new ServerServiceDefinition(serverServiceDefinition.CallHandlers.ToDictionary(x => x.Key, x => x.Value.Intercept(interceptor)));
} }
@ -68,8 +68,8 @@ namespace Grpc.Core.Interceptors
/// </remarks> /// </remarks>
public static ServerServiceDefinition Intercept(this ServerServiceDefinition serverServiceDefinition, params Interceptor[] interceptors) public static ServerServiceDefinition Intercept(this ServerServiceDefinition serverServiceDefinition, params Interceptor[] interceptors)
{ {
GrpcPreconditions.CheckNotNull(serverServiceDefinition, "serverServiceDefinition"); GrpcPreconditions.CheckNotNull(serverServiceDefinition, nameof(serverServiceDefinition));
GrpcPreconditions.CheckNotNull(interceptors, "interceptors"); GrpcPreconditions.CheckNotNull(interceptors, nameof(interceptors));
foreach (var interceptor in interceptors.Reverse()) foreach (var interceptor in interceptors.Reverse())
{ {

@ -76,7 +76,7 @@ namespace Grpc.Core.Internal
{ {
if (!(e is RpcException)) if (!(e is RpcException))
{ {
Logger.Warning(e, "Exception occured in handler or interceptors."); Logger.Warning(e, "Exception occurred in the handler or an interceptor.");
} }
status = HandlerUtils.GetStatusFromExceptionAndMergeTrailers(e, context.ResponseTrailers); status = HandlerUtils.GetStatusFromExceptionAndMergeTrailers(e, context.ResponseTrailers);
} }
@ -138,7 +138,7 @@ namespace Grpc.Core.Internal
{ {
if (!(e is RpcException)) if (!(e is RpcException))
{ {
Logger.Warning(e, "Exception occured in handler or interceptors."); Logger.Warning(e, "Exception occurred in the handler or an interceptor.");
} }
status = HandlerUtils.GetStatusFromExceptionAndMergeTrailers(e, context.ResponseTrailers); status = HandlerUtils.GetStatusFromExceptionAndMergeTrailers(e, context.ResponseTrailers);
} }
@ -201,7 +201,7 @@ namespace Grpc.Core.Internal
{ {
if (!(e is RpcException)) if (!(e is RpcException))
{ {
Logger.Warning(e, "Exception occured in handler or interceptor."); Logger.Warning(e, "Exception occurred in the handler or an interceptor.");
} }
status = HandlerUtils.GetStatusFromExceptionAndMergeTrailers(e, context.ResponseTrailers); status = HandlerUtils.GetStatusFromExceptionAndMergeTrailers(e, context.ResponseTrailers);
} }
@ -262,7 +262,7 @@ namespace Grpc.Core.Internal
{ {
if (!(e is RpcException)) if (!(e is RpcException))
{ {
Logger.Warning(e, "Exception occured in handler or interceptor."); Logger.Warning(e, "Exception occurred in the handler or an interceptor.");
} }
status = HandlerUtils.GetStatusFromExceptionAndMergeTrailers(e, context.ResponseTrailers); status = HandlerUtils.GetStatusFromExceptionAndMergeTrailers(e, context.ResponseTrailers);
} }
@ -313,7 +313,7 @@ namespace Grpc.Core.Internal
public IServerCallHandler Intercept(Interceptor interceptor) public IServerCallHandler Intercept(Interceptor interceptor)
{ {
return this; // Do not intercept unimplemented services return this; // Do not intercept unimplemented methods.
} }
} }

Loading…
Cancel
Save