-
Notifications
You must be signed in to change notification settings - Fork 161
getting started
胡锋 edited this page May 29, 2018
·
3 revisions
yarn add dubbo2.js # npm install dubbo2.js --save
const dubbo = Dubbo.from({
application //记录应用的名称,zookeeper的调用时候写入consumer 类型:({name: string};) 可选
register //设置zookeeper注册中心地址 必填 类型string
interfaces //设置zk监听的接口名称 类型 Array<string> 必填
});
const services = dubbo.proxyService({
//代理的服务接口 - string 必传
dubboInterface: 'com.alibaba.dubbo.demo.DemoService',
//服务接口的版本 - string 必传
version: '1.0.0',
//超时时间 number 可选
timeout: 10
//所属组 string 可选
group: 'qianmi',
//接口内的方法 - Array<Function> 必传
methods: {
//method name
sayHello(params) {
return [
params
]
}
},
})
(async () => {
//echo dubbo service method return res, err.
const {res, err} = await service.sayHello();
})();