• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript grpc-client.Client类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@restorecommerce/grpc-client.Client的典型用法代码示例。如果您正苦于以下问题:TypeScript Client类的具体用法?TypeScript Client怎么用?TypeScript Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: before

  before(async function setup() {
    cfg = sconfig(process.cwd() + '/test');
    const logger = new chassis.Logger(cfg.get('logger'));

    events = new Events(cfg.get('events:kafka'), logger);
    await events.start();

    const topics = cfg.get('events:kafka:topics');
    testTopic = events.topic(cfg.get('events:kafka:topics:test.resource:topic'));
    commandTopic = events.topic(cfg.get('events:kafka:topics:command:topic'));
    // subscribe all response events
    for (let eventName of cfg.get('events:kafka:topics:command:events')) {
      await commandTopic.on(eventName, eventListener);
    }

    server = new Server(cfg.get('server'), logger);
    db = await database.get(cfg.get('database:arango'), logger);
    await db.truncate();

    const config = cfg.get();
    delete config.database.nedb;  // not supported in default implementation

    const cis = new CommandInterface(server, config, logger, events);
    await server.bind('commandinterface', cis);
    await server.start();

    const client = new Client(cfg.get('client:commandinterface'), logger);
    service = await client.connect();
  });
开发者ID:restorecommerce,项目名称:chassis-srv,代码行数:29,代码来源:command_test.ts


示例2: beforeEach

 beforeEach(async function connect() {
   const cfg = await chassis.config.get();
   const logger = new Logger(cfg.get('logger'));
   client = new Client(cfg.get('client:reflection'), logger);
   const reflection: chassis.ServerReflection = await client.connect();
   serverReflectionInfo = await reflection.serverReflectionInfo();
 });
开发者ID:restorecommerce,项目名称:chassis-srv,代码行数:7,代码来源:reflection_test.ts


示例3: checkEndpoint

 async function checkEndpoint() {
   const cfg = await chassis.config.get();
   const logger = new Logger(cfg.get('logger'));
   const client: Client = new Client(cfg.get('client:reflection'), logger);
   const reflectionClient: chassis.ServerReflection = await client.connect();
   const reflection = await reflectionClient.serverReflectionInfo();
   await reflection.end();
   await client.end();
 });
开发者ID:restorecommerce,项目名称:chassis-srv,代码行数:9,代码来源:reflection_test.ts


示例4: describe

 describe('calling endpoint ServerReflectionInfo', () => {
   let client: Client;
   let serverReflectionInfo;
   beforeEach(async function connect() {
     const cfg = await chassis.config.get();
     const logger = new Logger(cfg.get('logger'));
     client = new Client(cfg.get('client:reflection'), logger);
     const reflection: chassis.ServerReflection = await client.connect();
     serverReflectionInfo = await reflection.serverReflectionInfo();
   });
   afterEach(async function disconnect() {
     await serverReflectionInfo.end();
     await client.end();
   });
   describe('with fileByFilename request', () => {
     it('should return file by file name response',
       async function checkFileByFilename() {
         await serverReflectionInfo.write({
           file_by_filename: 'test.proto',
         });
         let resp = await serverReflectionInfo.read();
         resp = await new Promise((resolve, reject) => {
           resp((err, response) => {
             if (err)
               reject(err);
             resolve(response);
           });
         });
         should.exist(resp);
         should.exist(resp.file_descriptor_response);
         should.exist(resp.file_descriptor_response.file_descriptor_proto);
         resp.file_descriptor_response.file_descriptor_proto.should.be.length(1);
       });
   });
   describe('with fileContainingSymbol request', () => {
     it('should return file containing path / symbol response',
       async function checkFileContainingSymbol() {
         await serverReflectionInfo.write({
           file_containing_symbol: 'test.Test',
         });
         let resp = await serverReflectionInfo.read();
         resp = await new Promise((resolve, reject) => {
           resp((err, response) => {
             if (err)
               reject(err);
             resolve(response);
           });
         });
         should.exist(resp);
         should.exist(resp.file_descriptor_response);
         should.exist(resp.file_descriptor_response.file_descriptor_proto);
         resp.file_descriptor_response.file_descriptor_proto.should.be.length(1);
       });
   });
   describe('with fileContainingExtension request', () => {
     it('should return file extension response',
       async function checkFileContainingExtension() {
         await serverReflectionInfo.write({
           file_containing_extension: {
             containing_type: 'test.ExtendMe',
             extension_number: 126,
           },
         });
         let resp = await serverReflectionInfo.read();
         resp = await new Promise((resolve, reject) => {
           resp((err, response) => {
             if (err)
               reject(err);
             resolve(response);
           });
         });
         should.exist(resp);
         should.exist(resp.file_descriptor_response);
         should.exist(resp.file_descriptor_response.file_descriptor_proto);
         resp.file_descriptor_response.file_descriptor_proto.should.be.length(1);
       });
   });
   describe('with allExtensionNumbersOfType request', () => {
     it('should get allExtensionsNumbers response',
       async function checkallExtensionNumbersOfType() {
         await serverReflectionInfo.write({
           all_extension_numbers_of_type: 'test.ExtendMe',
         });
         let resp = await serverReflectionInfo.read();
         resp = await new Promise((resolve, reject) => {
           resp((err, response) => {
             if (err)
               reject(err);
             resolve(response);
           });
         });
         should.exist(resp);
         should.exist(resp.all_extension_numbers_response);
         should.exist(resp.all_extension_numbers_response.base_type_name);
         // The response from the Reflection service for full name includes a leading dot.
         resp.all_extension_numbers_response.base_type_name.should.equal('.test.ExtendMe');
         should.exist(resp.all_extension_numbers_response.extension_number);
         resp.all_extension_numbers_response.extension_number.should.be.length(1);
         resp.all_extension_numbers_response.extension_number[0].should.equal(126);
       });
//.........这里部分代码省略.........
开发者ID:restorecommerce,项目名称:chassis-srv,代码行数:101,代码来源:reflection_test.ts


示例5: afterEach

 afterEach(async function disconnect() {
   await serverReflectionInfo.end();
   await client.end();
 });
开发者ID:restorecommerce,项目名称:chassis-srv,代码行数:4,代码来源:reflection_test.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript kafka-client.Events类代码示例发布时间:2022-05-28
下一篇:
TypeScript core.createModel函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap