當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。