Fix code and documentation to pass `deadline` metadata as a String. (#1269)

- As Metadata is a <string, string> map per Closure and TS definition.
This commit is contained in:
Eryu Xia 2022-08-30 16:08:35 -07:00 committed by GitHub
parent ccef7bd239
commit a5bd765d1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View File

@ -225,7 +225,7 @@ should be a Unix timestamp, in milliseconds.
var deadline = new Date();
deadline.setSeconds(deadline.getSeconds() + 1);
client.sayHelloAfterDelay(request, {deadline: deadline.getTime()},
client.sayHelloAfterDelay(request, {deadline: deadline.getTime().toString()},
(err, response) => {
// err will be populated if the RPC exceeds the deadline
...
@ -318,4 +318,4 @@ Multiple proxies support the gRPC-web protocol.
[gRPC]: https://grpc.io
[grpc-web-docs]: https://grpc.io/docs/languages/web
[gRPC-web Go Proxy]: https://github.com/improbable-eng/grpc-web/tree/master/go/grpcwebproxy
[Hello World example]: net/grpc/gateway/examples/helloworld
[Hello World example]: net/grpc/gateway/examples/helloworld

View File

@ -84,8 +84,8 @@ testSuite({
deadline.setSeconds(deadline.getSeconds() + 1);
await new Promise((resolve, reject) => {
client.rpcCall(
'url', new MockRequest(), {'deadline': deadline}, methodDescriptor,
(error, response) => {
'url', new MockRequest(), {'deadline': deadline.getTime().toString()},
methodDescriptor, (error, response) => {
assertNull(error);
resolve();
});

View File

@ -52,8 +52,10 @@ function doEmptyUnary(done) {
function doEmptyUnaryWithDeadline(done) {
var testService = new TestServiceClient(SERVER_HOST, null, null);
const deadlineMs = 1000; // 1 second
testService.emptyCall(new Empty(), {deadline: Date.now() + deadlineMs},
const deadline = new Date();
deadline.setSeconds(deadline.getSeconds() + 1);
testService.emptyCall(new Empty(), {deadline: deadline.getTime().toString()},
(err, response) => {
assert.ifError(err);
assert(response instanceof Empty);