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

feat: JS clients can provide custom grpc transports #6476

Merged
merged 15 commits into from
Dec 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve dummy test, still suppressed
niloc132 committed Dec 10, 2024
commit a35b0e3a672dfb7eecec007eb008e85b6a0e764a
Original file line number Diff line number Diff line change
@@ -79,6 +79,7 @@ public void testFetchGrpcTransport() {
return;
}
setupDhInternal().then(ignore -> {
delayTestFinish(7101);
ConnectOptions connectOptions = new ConnectOptions();
connectOptions.transportFactory = makeFetchTransportFactory();
CoreClient coreClient = new CoreClient(localServer, connectOptions);
@@ -89,19 +90,29 @@ public void testFetchGrpcTransport() {

/**
* Dummy transport that just sends a single message and receives a single message. Doesn't actually talk to
* the server, headers are empty, and the message is always 5 byte proto payload "no data".
* the server, headers are empty, and the message is always 5 byte proto payload "no data", followed by
* trailers signifying success.
*/
private native GrpcTransportFactory makeDummyTransportFactory() /*-{
return {
bmingles marked this conversation as resolved.
Show resolved Hide resolved
create: function(options) {
return {
start: function(metadata) {
// no-op
// empty headers
$wnd.setTimeout(function() {options.onHeaders({}, 200);}, 0);
},
sendMessage: function(msgBytes) {
// no-op
$wnd.setTimeout(function() {options.onChunk(new Uint8Array(5));}, 0);
// empty payload
var empty = new $wnd.Uint8Array(5);
var successTrailers = new $wnd.Uint8Array(5);
successTrailers[0] = 128;
new TextEncoding('utf-8').encodeInto('grpc-status:1', successTrailers.subarray(1));

$wnd.setTimeout(function() {
options.onChunk(empty);
debugger;
options.onChunk(successTrailers);
}, 0);
},
finishSend: function() {
// no-op
@@ -115,13 +126,15 @@ private native GrpcTransportFactory makeDummyTransportFactory() /*-{
};
}-*/;

// public void testDummyGrpcTransport() {
// setupDhInternal().then(ignore -> {
// ConnectOptions connectOptions = new ConnectOptions();
// connectOptions.transportFactory = makeDummyTransportFactory();
// CoreClient coreClient = new CoreClient(localServer, connectOptions);
// return coreClient.login(JsPropertyMap.of("type", CoreClient.LOGIN_TYPE_ANONYMOUS))
// .then(ignore2 -> Promise.resolve(coreClient));
// }).then(this::finish).catch_(this::report);
// }
public void ignore_testDummyGrpcTransport() {
setupDhInternal().then(ignore -> {
delayTestFinish(7102);
ConnectOptions connectOptions = new ConnectOptions();
connectOptions.transportFactory = makeDummyTransportFactory();
connectOptions.debug = true;
CoreClient coreClient = new CoreClient(localServer, connectOptions);
return coreClient.login(JsPropertyMap.of("type", CoreClient.LOGIN_TYPE_ANONYMOUS))
.then(ignore2 -> Promise.resolve(coreClient));
}).then(this::finish).catch_(this::report);
}
}