import { Context , Dubbo , setting } from 'apache-dubbo-js' ; import { EggApplication } from 'egg' ; import service from './service' ; declare module 'egg' { export interface EggApplication { dubbo : Dubbo < typeof service > ; } } const dubboSetting = setting . match ( [ 'org.apache.dubbo.demo.DemoProvider' , 'org.apache.dubbo.demo.ErrorProvider' , ] , { version : '1.0.0' , } ) . match ( 'org.apache.dubbo.demo.BasicTypeProvider' , { version : '2.0.0' } ) ; export default ( app ) => { const { application , registry } = app . config . dubbo ; const dubbo = new Dubbo < typeof service > ( { application , registry , service , dubboSetting , } ) ; dubbo . subscribe ( { onTrace ( err ) { console . log ( err ) ; } , } ) ; dubbo . use ( async ( ctx , next ) => { const start = Date . now ( ) ; await next ( ) ; const end = Date . now ( ) ; app . coreLogger . info ( `${ ctx . dubboInterface } was invoked, cost-time ${ end - start }` ) ; } ) ; app . dubbo = dubbo ; } ;