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


TypeScript dubbo2.js.Dubbo类代码示例

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


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

示例1: default

export default (app: EggApplication) => {
  const dubboSetting = setting
    .match(
      [
        'com.alibaba.dubbo.demo.DemoProvider',
        'com.alibaba.dubbo.demo.ErrorProvider',
      ],
      {
        version: '1.0.0',
      },
    )
    .match('com.alibaba.dubbo.demo.BasicTypeProvider', {version: '2.0.0'});

  const dubbo = new Dubbo<typeof service>({
    application: {name: 'node-egg-bff'},
    register: 'localhost:2181',
    service,
    dubboSetting,
  });

  // extends middleware
  dubbo.use(async (ctx: Context, next: any) => {
    const start = Date.now();
    await next();
    const end = Date.now();
    app.coreLogger.info(
      `${ctx.dubboInterface} was invoked, cost-time ${end - start}`,
    );
  });

  app.dubbo = dubbo;
};
开发者ID:hufeng,项目名称:node-jsonrpc-dubbo,代码行数:32,代码来源:index.ts

示例2: DemoProvider

export function DemoProvider(dubbo: Dubbo): IDemoProvider {
  return dubbo.proxyService<IDemoProvider>({
    dubboInterface: 'com.alibaba.dubbo.demo.DemoProvider',
    methods: DemoProviderWrapper,
  });
}
开发者ID:hufeng,项目名称:node-jsonrpc-dubbo,代码行数:6,代码来源:DemoProvider.ts

示例3: next

const service = {
  DemoProvider,
};

const dubboSetting = setting
  .match('com.alibaba.dubbo.demo.BasicTypeProvider', {
    version: '2.0.0',
  })
  .match('com.alibaba.dubbo.demo.DemoProvider', {version: '1.0.0'})
  .match('com.alibaba.dubbo.demo.ErrorProvider', {version: '1.0.0'});

const dubbo = new Dubbo<typeof service>({
  application: {name: '@qianmi/node-dubbo'},
  register: 'localhost:2181',
  dubboInvokeTimeout: 0.001,
  service,
  dubboSetting,
});

//use middleware
dubbo.use(async function test(ctx, next) {
  const startTime = Date.now();
  await next();
  const endTime = Date.now();
  const {
    request: {dubboInterface, methodName},
  } = ctx;
  console.log(
    `timeout: invoke ${dubboInterface}#${methodName} costTime: ${endTime -
      startTime}`,
开发者ID:hufeng,项目名称:node-jsonrpc-dubbo,代码行数:30,代码来源:dubbo-timeout-test.ts

示例4: BasicTypeProvider

export function BasicTypeProvider(dubbo: Dubbo): IBasicTypeProvider {
  return dubbo.proxyService<IBasicTypeProvider>({
    dubboInterface: 'com.alibaba.dubbo.demo.BasicTypeProvider',
    methods: BasicTypeProviderWrapper,
  });
}
开发者ID:hufeng,项目名称:node-jsonrpc-dubbo,代码行数:6,代码来源:BasicTypeProvider.ts

示例5: next

//dubbo-setting
const dubboSetting = setting
  .match('com.alibaba.dubbo.demo.BasicTypeProvider', {
    version: '2.0.0',
  })
  .match(
    [
      'com.alibaba.dubbo.demo.DemoProvider',
      'com.alibaba.dubbo.demo.ErrorProvider',
    ],
    {version: '1.0.0'},
  );

const dubbo = new Dubbo<typeof service>({
  application: {name: '@qianmi/node-dubbo'},
  register: 'localhost:2181',
  service,
  dubboSetting,
});

//use middleware
dubbo.use(async function costtime(ctx, next) {
  const startTime = Date.now();
  await next();
  const endTime = Date.now();
  const {
    request: {dubboInterface, methodName},
  } = ctx;

  console.log(
    `invoke ${dubboInterface}#${methodName} costTime: ${endTime - startTime}`,
  );
开发者ID:hufeng,项目名称:node-jsonrpc-dubbo,代码行数:32,代码来源:dubbo-test.ts


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