forked from deephaven/deephaven-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: JS API should use GetConfigurationConstants for auth calls (deep…
…haven#5959) In addition to more closely following what other Deephaven clients do, this prevents an issue where Open/Next pairs of gRPC calls (to emulate a bidirectional call) can race each other to redeem a one-time use auth token. Fixes deephaven#5955
- Loading branch information
Showing
4 changed files
with
87 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
150 changes: 0 additions & 150 deletions
150
...-api/src/main/java/io/deephaven/web/client/api/barrage/stream/HandshakeStreamFactory.java
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
web/client-api/src/main/java/io/deephaven/web/client/api/grpc/UnaryWithHeaders.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending | ||
// | ||
package io.deephaven.web.client.api.grpc; | ||
|
||
import elemental2.promise.IThenable; | ||
import elemental2.promise.Promise; | ||
import io.deephaven.javascript.proto.dhinternal.grpcweb.Grpc; | ||
import io.deephaven.javascript.proto.dhinternal.grpcweb.grpc.Code; | ||
import io.deephaven.javascript.proto.dhinternal.grpcweb.unary.UnaryOutput; | ||
import io.deephaven.javascript.proto.dhinternal.grpcweb.unary.UnaryRpcOptions; | ||
import io.deephaven.web.client.api.WorkerConnection; | ||
|
||
public class UnaryWithHeaders { | ||
|
||
/** | ||
* Improbable-eng's grpc-web implementation doesn't pass headers to api callers - this changes the contract a bit so | ||
* that we can get a typed UnaryOutput with the headers/trailers intact. | ||
* | ||
* @param connection provides access to the metadata and the server url | ||
* @param methodDescriptor the service method to invoke | ||
* @return a promise that will resolve to the response plus headers/trailers, or reject with the headers/trailers | ||
* @param <Res> type of the message object | ||
*/ | ||
public static <Req, Res> Promise<UnaryOutput<Res>> call(WorkerConnection connection, Object methodDescriptor, | ||
Req request) { | ||
return new Promise<>((resolve, reject) -> { | ||
UnaryRpcOptions<Object, Object> props = UnaryRpcOptions.create(); | ||
props.setHost(connection.configServiceClient().serviceHost); | ||
props.setMetadata(connection.metadata()); | ||
props.setTransport(null);// ts doesn't expose these two, stick with defaults for now | ||
props.setDebug(false); | ||
props.setOnEnd(response -> { | ||
if (response.getStatus() != Code.OK) { | ||
reject.onInvoke(response); | ||
} else { | ||
resolve.onInvoke((IThenable<UnaryOutput<Res>>) response); | ||
} | ||
}); | ||
props.setRequest(request); | ||
Grpc.unary.onInvoke(methodDescriptor, props); | ||
}); | ||
} | ||
} |