Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve extensibility of gRPC invocation #669

Merged
merged 4 commits into from
Dec 10, 2019

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented Nov 27, 2019

Public changes:

  • Add new extensibility for registering a request delegate for a gRPC method
/// <summary>
/// Adds a method to a service. This method is handled by the specified <see cref="RequestDelegate"/>.
/// </summary>
/// <typeparam name="TRequest">Request message type for this method.</typeparam>
/// <typeparam name="TResponse">Response message type for this method.</typeparam>
/// <param name="method">The method description.</param>
/// <param name="pattern">The method pattern. This pattern is used by routing to match the method to an HTTP request.</param>
/// <param name="metadata">The method metadata. This metadata can be used by routing and middleware when invoking a gRPC method.</param>
/// <param name="invoker">The <see cref="RequestDelegate"/> that is executed when the method is called.</param>
public void AddMethod<TRequest, TResponse>(Method<TRequest, TResponse> method, RoutePattern pattern, IList<object> metadata, RequestDelegate invoker)
    where TRequest : class
    where TResponse : class
{
    var methodModel = new MethodModel(method, pattern, metadata, invoker);
    Methods.Add(methodModel);
}

Internal changes:

  • Add public gRPC method invokers. These handle service lifetime and interceptor pipeline. Can be used by default gRPC implementation, and gRPC+HTTPAPI and gRPC-Web. Update: Now internal and shared source. We can decide whether to make public in the future if there demand.
  • Add MethodOptions, an immutable view of the settings used to invoke a gRPC method (max request size, interceptors, compression). These are created from a collection of GrpcServiceOptions (mutable version). Lays the groundwork for per-method customization of settings.. Update: Now internal and shared source. We can decide whether to make public in the future.

@JamesNK
Copy link
Member Author

JamesNK commented Dec 6, 2019

I've greatly reduced the new API surface. Now there is just one new public method. Some code has moved to a shared source folder. If we ever decided to not share it then its simple to move it back again.

Ready for review @jtattermusch

@jtattermusch
Copy link
Contributor

jtattermusch commented Dec 9, 2019

Can you give a list of publicly visible changes? I went through the changes and noticed that besides, the new AddMethod overload you're also publishing IGrpcInterceptorActivator and IGrpcInterceptorActivator<TInterceptor> etc., so I wanted to make sure I didn't miss anything.

@jtattermusch
Copy link
Contributor

Overall looks lood, added a few questions. I'd also like a detailed review from @JunTaoLuo

@jtattermusch
Copy link
Contributor

Are the changes from #677 required for this PR? If not, I'd prefer merging the two separately.

@JamesNK
Copy link
Member Author

JamesNK commented Dec 10, 2019

Are the changes from #677 required for this PR? If not, I'd prefer merging the two separately.

It will be merged before this one.

Edit: #677 is merged.

@JamesNK JamesNK force-pushed the jamesnk/startup-extensibility2 branch from cd2b288 to c7e45b6 Compare December 10, 2019 03:22
@JamesNK JamesNK force-pushed the jamesnk/startup-extensibility2 branch from c7e45b6 to 4cb62b4 Compare December 10, 2019 03:24
Copy link
Contributor

@JunTaoLuo JunTaoLuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor nits.

@JamesNK JamesNK mentioned this pull request Dec 10, 2019
Copy link
Contributor

@jtattermusch jtattermusch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@JamesNK JamesNK merged commit afd37e4 into grpc:master Dec 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants