-
Notifications
You must be signed in to change notification settings - Fork 436
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
Transport options (variant B) #261
Transport options (variant B) #261
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This I like!
I noticed some tests failed - and the reason seems to be infrastructure issue, not the code issue. |
I'm afraid to say some of the tests in our CI setup are a bit flaky, I will rerun them if there appears to be something obviously wrong. It does raise a point though, could you add a test which just shows how to use this new fetch option functionality (and test that it works!)? |
Also see #259. @jonny-improbable I think we need to get Chrome-42 out sooner rather than later. |
I've opened #262 to deal with the CI failure (I hope) |
test/ts/src/testRpcCombinations.ts
Outdated
@@ -54,7 +55,8 @@ export function runWithHttp1AndHttp2(cb: (config: TestConfig) => void) { | |||
|
|||
export function runWithSupportedTransports(cb: (transport: grpc.TransportConstructor | undefined) => void) { | |||
const transports: {[key: string]: grpc.TransportConstructor | undefined} = { | |||
"defaultTransport": undefined | |||
"defaultTransport": undefined, | |||
"fetchWithOptions": fetchRequestWithOptions({}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume we may need to add this key to some test cases as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be used by all test cases as a way to provide transport - so it sohlud do the trick. Testing setup is rather complictaed, but seems to be prepared for testing custom transports like this. Would like a comment from @MarcusLongmuir on this.
(I think) I added the new API to tests. Don't really know if it's the correct way - let's see what CI does in response to this. |
The tests probably won't pass until #262 is merged regardless, but we can force this through if everything but Chrome-42 passes. |
What's going on with tests? They seems to be stuck - is it Travis CI that's not scheduling them to run? |
I think it's just limited to 5 concurrent runners per project, and some of the runners are taken up by my #262. Please wait :). |
From the previous test run: Safari now has some strange failures - https://travis-ci.org/improbable-eng/grpc-web/builds/443570174 |
I've restarted the safari tests. As you say, they shouldn't be affected by your changes. |
I uncovered another problem - transport implementations are not exported. I think I have to add a way to use this |
And it seems I need further help with tests - there are some failures in firefox when I test my |
If Firefox should default to MozXHR AFAIK - if we've broken that we need to fix it. Are there tests running on Firefox with fetch that shouldn't be? I'm not very familiar with the tests either I'm afraid, but you should be able to run it locally I assume? |
If you want, you can try reaching out to @MarcusLongmuir or @jonny-improbable or @easyCZ on the grpc-web slack (see README.md). |
I have to step out now, hopefully they'll see this PR and comment before I get back. |
Hmm, I have some reservations with this approach. The main reason being that one of the goals of grpc-web is to provide an abstraction over the underlying browser technology; hence why we have both The problem with this approach is that the caller is specifying the concrete transport to use; whilst In the past I've considered adding a My initial thinking might be to create a clear distinction between the 2 types of transport we have: 'Http' based and 'Socket' based (where the HttpTransport is an abstraction over A further step could be to make the WDYT? |
Well, the idea of this PR is to utilize the pre-existing ability to specify custom transport to fine-tune the underlying transport. The real goal here is to have the ability to fine-tune the transports (in particular - just the What you're proposing is all good, but providing knobs (as an opt in - for people that need those, like me when I had that particular usecase) for transport is, I'd say more important. And, since knobs for different transports will be different, a unified interface to all of the possible tweakable parameters is not required - and adding knobs is not therefore blocked by splitting Http/Stream transports. When interface for setting internal implementation details is ready - additional logic (like unified tweaking for unified |
There's something to be said for carefully adding API surface though, and if we can accomplish the same thing with a longer term goal, shouldn't we try that first? If we only need to expose credentials and they can both be shared between Fetch and XHR, lets do that now. |
Sure, why not. Especially that this PR just does that (for fetch), and we can implement simialr thing for XHR. We can also implement a "default" transport "withOptions", that would allow passing credentials, and setting them for |
Enjoying a glass of wine, I'm having an idea. Let me see if I can make some
time to code it up at the weekend.
…On Fri, 19 Oct 2018, 19:49 MOZGIII, ***@***.***> wrote:
Sure, why not. Especially that this PR just does that (for fetch), and we
can implement simialr thing for XHR. We can also implement a "default"
transport "withOptions", that would allow passing credentials, and setting
them for fetch/XHR, and either ignoring or thoring an error if it the
transport picked is not fetch not XHR. Does this plan seems reasonable?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#261 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMN-dkoeGv4gH29A3Mjwu44gt84e1wNks5umh7IgaJpZM4Xv2Vq>
.
|
Superseded by #265 |
Following on from the conversation in #261 this PR allows the user to configure the behavior of a given Transport, separate from the pre-existing TransportOptions interface which deals with passing request state (ie: host, url, callbacks, etc). To facilitate this change, the transport option passed to the unary, invoke and client functions is now expected to meet the new grpc.TransportFactory interface, ie: a func which can accept zero or more args and will return a grpc.Transport instance. ``` grpc.unary(BookService.GetBook, { request: getBookRequest, host: host, transport: grpc.HttpTransport({ credentials: 'include' }), onEnd: ( /*...*/ ) }); ``` Note this results in a breaking change for anyone currently using the Websocket Transport; instead of specifying: ``` transport: gprc.WebsocketTransportFactory ``` They would instead now call: ``` transport: grpc.WebsocketTransport() ``` This change also spurred me to to fix #191 and #141 by extracting the 'Node HTTP' transport out from the gprc-web-client package and into a new module: grpc-web-node-http-client, which will be published to npm separately. As one thing leads to another, extracting node-grpc-web-node-http-transport led to implement grpc.setDefaultTransport() which allows the user to specify which TransportFactory` should be .invoked if none is supplied in the options. ## Breaking Changes transport option passed to unary, invoke and client is now expected to by an instance of Transport, not a reference to a function which will return a Transport when invoked. grpc-web-client no longer auto-selects a suitable transport in a NodeJS environment; users of grpc-web-client in a NodeJS environment will need to depend upon grpc-web-node-http-transport and make use of grpc.setDefaultTranpsport().
See #103
This better captures the idea I poposed at #103. It's also simpler than #260 and users have to opt-in to specify custom tranport.