-
Notifications
You must be signed in to change notification settings - Fork 238
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
L5: Add client interceptor support to NodeJS #14
L5: Add client interceptor support to NodeJS #14
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed the CLA under Netflix |
CLAs look good, thanks! |
I have created a grpc-io discussion about this proposal at https://groups.google.com/forum/#!topic/grpc-io/LxT1JjN33Q4. Please add a link to it in the proposal. |
This removes the batch-handling API and makes additions to address the short-circuiting and delay use cases.
Please rename to L5-something-something.md |
I'm sorry for the delay. I'm the maintainer for the Node gRPC library, so you should make me the reviewer listed in the doc. I am also approving this for submission, so you should also change the state to "Final". |
We are exploring some minor changes to the interceptor API to bring it more in line with the Java interceptor framework. If they work out I will have an update to the proposal next week. |
Reflects a new API where each interceptor has a parameter which can construct the next interceptor in the chain. Updates terminology and examples.
Are you still planning to make changes to this API? Do you have an ETA for those changes? |
Proposal has been updated with the API change. The new API allows interceptor developers to construct a new call at any time with all the downstream interceptors, which is important for the 'retry' use case. |
+1 for this |
Also, @drobertduke can you make the previously mentioned changes to the information in the document's header? |
A NodeJS implementation of client-side interceptors, as described in the proposal: grpc/proposal#14
@wenbozhu @stanley-cheung friendly ping... Can you please confirm this looks fine for gRPC-Web? |
@wenbozhu friendly ping |
@drobertduke Could you briefly mention the difference between the Node proposal and the existing Java interceptor framework, if any, ignoring threading or language-specific design choices? I don't see flow-control is addressed explicitly, i.e. pause/resume of Node streams. Are you using Node streams to manage flow-control today? Re: the spec, I don't see how exceptions (from interceptors) are to be handled; or interceptors are allowed to terminate the request. Specifically, if an interceptor terminates a request, will (way-out) handlers of in-stack interceptors be invoked in order ... e.g. if an auth interceptor fails a request, will the outer logger interceptor sees an error response? === The overall proposal seems to me a rather low-level interceptor, which is useful for infrastructure or framework providers but may prove to be too complicated (powerful?) for normal users. This is just a note. |
@wenbozhu Java: https://gist.github.com/drobertduke/e48d08645ba872a933d192cd232bf3b7 NodeJS: https://gist.github.com/drobertduke/239e5668a20c8114626873886c754c9e The listener methods have been renamed for clarity and there are minor interface differences but structurally they are very close. We have extensive interceptor implementations in Java and we need a NodeJS interceptor framework with a similar API to make re-implementation possible. re: flow-control, before this PR NodeJS clients were using Node streams to manage flow control, and this PR does not change that. I'm not sure the flow control APIs exposed in grpc-java make sense when applied to Node streams but I'm happy to reconsider if there are specific requests for functionality. re: exceptions, the framework follows the Joyent recommendation on exceptions, which is essentially 'Don't catch them unless you know they are operational errors'. Interceptor authors are expected to make their own determinations about handling exceptions. re: terminating the request, interceptors can terminate the request in the same way Java interceptors terminate requests, and this causes 'outer' interceptors to be skipped (same as Java). Here's an example block which terminates a request when a client-side concurrency limit is reached:
Should I make this more clear in the proposal? Can you expand on what you mean by low-level? It follows a very similar API to grpc-java. A simpler API was considered but it would have ruled out the implementation of advanced functionality like client-side caching. |
Thanks for the examples. Re: flow-control, yes, I understand that the Java flow-control must be different than the pause/resume style of flow-control Node streams offers. I was asking if pause/resume need be intercepted too. Also, I am curious how pause/resume are actually used today, e.g. in your experience (independently of the interceptor design). Re: exceptions, early termination, I think the spec should mention those conditions. Not sure if outer interceptors should be skipped, but this is not a Node specific issue. Otherwise, LGTM. Thanks. |
The flow control question brings up another one: for outgoing intercepted calls, how many times can each |
A NodeJS implementation of client-side interceptors, as described in the proposal: grpc/proposal#14
A NodeJS implementation of client-side interceptors, as described in the proposal: grpc/proposal#14
@wenbozhu We're not using pause/resume on gRPC streams and I don't know of a use case for intercepting them. I've added some language to the spec to describe exception handling and the short-circuit behavior. @murgatroid99 |
@drobertduke If |
@mehrdada To retry, create a new "call" using the interceptor's This is similar to how we implement retries in Java. I don't see any open-source examples of retry interceptors but the |
@drobertduke I believe the concrete use-case @wenbozhu particularly cares about is being able to defer sending initial headers to the server in streaming calls until after the first request message is seen by the interceptor and only then start the actual request on the wire, so that you are able to copy some fields from the request to the RPC headers within an interceptor. |
There's an example of a unary interceptor for a similar case in the proposal: https://github.com/grpc/proposal/pull/14/files#diff-c1aee0ddae63a3e9a9ba050796cd4b58R279 The caching interceptor linked above delays sending the headers or message until the cache is checked. To satisfy your use case, you could store the
|
@drobertduke Thanks for the clarification. |
@murgatroid99 @wenbozhu shall we merge this or are there any more questions? |
A NodeJS implementation of client-side interceptors, as described in the proposal: grpc/proposal#14
A NodeJS implementation of client-side interceptors, as described in the proposal: grpc/proposal#14
A NodeJS implementation of client-side interceptors, as described in the proposal: grpc/proposal#14
What's the status of this proposal? |
Merged and implemented for a while now.
…On Sat, Apr 28, 2018, 12:48 Nadeem Bitar ***@***.***> wrote:
What's the status of this proposal?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#14 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AG8bpkqYIKqzuOIbYU3ystMKbH12uSZ3ks5ttMeogaJpZM4MJeCn>
.
|
No description provided.