当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript grpc.invoke方法代码示例

本文整理汇总了TypeScript中@improbable-eng/grpc-web.grpc.invoke方法的典型用法代码示例。如果您正苦于以下问题:TypeScript grpc.invoke方法的具体用法?TypeScript grpc.invoke怎么用?TypeScript grpc.invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@improbable-eng/grpc-web.grpc的用法示例。


在下文中一共展示了grpc.invoke方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

      it("should report failure for a trailers-only response", (done) => {
        let didGetOnHeaders = false;
        let didGetOnMessage = false;

        const ping = new PingRequest();

        grpc.invoke(FailService.NonExistant, { // The test server hasn't registered this service, so it should return an error
          debug: DEBUG,
          transport: transport,
          request: ping,
          host: emptyHost,
          onHeaders: (headers: grpc.Metadata) => {
            DEBUG && debug("headers", headers);
            didGetOnHeaders = true;
            assert.deepEqual(headers.get("grpc-status"), ["12"]);
            assert.deepEqual(headers.get("grpc-message"), ["unknown service improbable.grpcweb.test.FailService"]);
          },
          onMessage: (message: Empty) => {
            didGetOnMessage = true;
          },
          onEnd: (status: grpc.Code, statusMessage: string, trailers: grpc.Metadata) => {
            DEBUG && debug("status", status, "statusMessage", statusMessage, "trailers", trailers);
            assert.strictEqual(statusMessage, "unknown service improbable.grpcweb.test.FailService");
            assert.strictEqual(status, 12);
            assert.deepEqual(trailers.get("grpc-status"), ["12"]);
            assert.deepEqual(trailers.get("grpc-message"), ["unknown service improbable.grpcweb.test.FailService"]);
            assert.ok(didGetOnHeaders);
            assert.ok(!didGetOnMessage);
            done();
          }
        });
      });
开发者ID:mwitkow,项目名称:grpc-browser-compat,代码行数:32,代码来源:invoke.spec.ts

示例2: it

      it("should allow the caller to abort an rpc before it completes", () => {
        let transportCancelFuncInvoked = false;

        const cancellationSpyTransport = () => {
          return {
            sendMessage: () => {
            },
            finishSend() {
            },
            start: () => {
            },
            cancel: () => {
              transportCancelFuncInvoked = true;
            },
          }
        };

        const ping = new PingRequest();
        ping.setValue("hello world");

        const reqObj = grpc.invoke(TestService.Ping, {
          debug: DEBUG,
          request: ping,
          host: testHostUrl,
          transport: cancellationSpyTransport,
          onEnd: (status: grpc.Code, statusMessage: string, trailers: grpc.Metadata) => {
          },
        });

        reqObj.close();

        assert.equal(transportCancelFuncInvoked, true, "transport's cancel func must be invoked");
      });
开发者ID:mwitkow,项目名称:grpc-browser-compat,代码行数:33,代码来源:cancellation.spec.ts

示例3: debug

 assert.throw(() => {
   grpc.invoke(TestService.PingStream, {
     debug: DEBUG,
     transport: transport,
     request: ping,
     host: testHostUrl,
     onHeaders: (headers: grpc.Metadata) => {
       DEBUG && debug("headers", headers);
     },
     onMessage: (message: PingResponse) => {
       DEBUG && debug("message", message);
     },
     onEnd: (status: grpc.Code, statusMessage: string, trailers: grpc.Metadata) => {
       DEBUG && debug("status", status, "statusMessage", statusMessage);
     }
   })
 }, ".invoke cannot be used with client-streaming methods. Use .client instead.");
开发者ID:mwitkow,项目名称:grpc-browser-compat,代码行数:17,代码来源:invoke.spec.ts


注:本文中的@improbable-eng/grpc-web.grpc.invoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。