Skip to content
Permalink
Browse files
Merge remote-tracking branch 'origin/master'
  • Loading branch information
creasy2010 committed May 23, 2018
2 parents 3488c38 + 9246a7e commit a8804a92ae7909d05a5fc93ed58e0e2a473226e1
Show file tree
Hide file tree
Showing 57 changed files with 65 additions and 3,223 deletions.
@@ -4,11 +4,11 @@ const dubbo = new Dubbo({
application: {name: 'dubbo-node-consumer'},
register: 'localhost:2181',
dubboVersion: '2.0.0',
interfaces: ['com.alibaba.dubbo.demo.DemoService'],
interfaces: ['com.alibaba.dubbo.demo.DemoProvider'],
});

const demoService = dubbo.proxyService({
dubboInterface: 'com.alibaba.dubbo.demo.DemoService',
dubboInterface: 'com.alibaba.dubbo.demo.DemoProvider',
version: '1.0.0',
methods: {
sayHello(name) {
@@ -5,14 +5,14 @@ const dubbo = new Dubbo({
register: 'localhost:2181',
dubboVersion: '2.0.0',
interfaces: [
'com.alibaba.dubbo.demo.DemoService',
'com.alibaba.dubbo.demo.BasicTypeService',
'com.alibaba.dubbo.demo.ErrorService',
'com.alibaba.dubbo.demo.DemoProvider',
'com.alibaba.dubbo.demo.BasicTypeProvider',
'com.alibaba.dubbo.demo.ErrorProvider',
],
});

const demoService = dubbo.proxyService({
dubboInterface: 'com.alibaba.dubbo.demo.DemoService',
dubboInterface: 'com.alibaba.dubbo.demo.DemoProvider',
version: '1.0.0',
methods: {
sayHello(name) {
@@ -36,7 +36,7 @@ const demoService = dubbo.proxyService({
});

const basicTypeService = dubbo.proxyService({
dubboInterface: 'com.alibaba.dubbo.demo.BasicTypeService',
dubboInterface: 'com.alibaba.dubbo.demo.BasicTypeProvider',
version: '2.0.0',
methods: {
testBasicType() {
@@ -51,7 +51,7 @@ const basicTypeService = dubbo.proxyService({
});

const errorService = dubbo.proxyService({
dubboInterface: 'com.alibaba.dubbo.demo.ErrorService',
dubboInterface: 'com.alibaba.dubbo.demo.ErrorProvider',
version: '1.0.0',
methods: {
errorTest() {
@@ -5,9 +5,9 @@ const dubbo = new Dubbo({
register: 'localhost:2181',
dubboVersion: '2.0.0',
interfaces: [
'com.alibaba.dubbo.demo.DemoService',
'com.alibaba.dubbo.demo.BasicTypeService',
'com.alibaba.dubbo.demo.ErrorService',
'com.alibaba.dubbo.demo.DemoProvider',
'com.alibaba.dubbo.demo.BasicTypeProvider',
'com.alibaba.dubbo.demo.ErrorProvider',
],
});

@@ -19,8 +19,8 @@ dubbo.use(async function costTime(ctx, next) {
console.log('end makecostTime->', endTime - startTime);
});

const demoService = dubbo.proxyService({
dubboInterface: 'com.alibaba.dubbo.demo.DemoService',
const demoProvider = dubbo.proxyService({
dubboInterface: 'com.alibaba.dubbo.demo.DemoProvider',
version: '1.0.0',
methods: {
sayHello(name) {
@@ -43,8 +43,8 @@ const demoService = dubbo.proxyService({
},
});

const basicTypeService = dubbo.proxyService({
dubboInterface: 'com.alibaba.dubbo.demo.BasicTypeService',
const basicTypeProvider = dubbo.proxyService({
dubboInterface: 'com.alibaba.dubbo.demo.BasicTypeProvider',
version: '2.0.0',
methods: {
testBasicType() {
@@ -58,8 +58,8 @@ const basicTypeService = dubbo.proxyService({
},
});

const errorService = dubbo.proxyService({
dubboInterface: 'com.alibaba.dubbo.demo.ErrorService',
const errorProvider = dubbo.proxyService({
dubboInterface: 'com.alibaba.dubbo.demo.ErrorProvider',
version: '1.0.0',
methods: {
errorTest() {
@@ -69,7 +69,7 @@ const errorService = dubbo.proxyService({
});

module.exports = {
demoService,
errorService,
basicTypeService,
demoProvider,
errorProvider,
basicTypeProvider,
};
@@ -1,7 +1,7 @@
const Koa = require('koa');
const Router = require('koa-router');
// const {tracer} = require('dubbo2.js');
const {demoService, basicTypeService, errorService} = require('./dubbo');
const {demoProvider, basicTypeProvider, errorProvider} = require('./dubbo');

const app = new Koa();
const router = new Router();
@@ -11,38 +11,38 @@ router.get('/', ctx => {
});

router.get('/hello', async ctx => {
const {res, err} = await demoService.sayHello('test');
const {res, err} = await demoProvider.sayHello('test');
ctx.body = err ? err.message : res;
});

router.get('/user', async ctx => {
const {res, err} = await demoService.getUserInfo();
const {res, err} = await demoProvider.getUserInfo();
ctx.body = res || err.message;
});

router.get('/echo', async ctx => {
ctx.body = await demoService.echo();
ctx.body = await demoProvider.echo();
});

router.get('/type', async ctx => {
const {res, err} = await basicTypeService.testBasicType();
const {res, err} = await basicTypeProvider.testBasicType();
ctx.body = res;
});

router.get('/exp', async ctx => {
const {err, res} = await errorService.errorTest();
const {err, res} = await errorProvider.errorTest();
console.log(err);
ctx.body = 'ok';
});

router.get('/tracer', async ctx => {
const {res: hello} = await demoService.sayHello('test');
const {res: userInfo} = await demoService.getUserInfo();
const {res: hello} = await demoProvider.sayHello('test');
const {res: userInfo} = await demoProvider.getUserInfo();

setTimeout(async () => {
await basicTypeService.testBasicType();
await basicTypeProvider.testBasicType();
process.nextTick(() => {
demoService.getUserInfo();
demoProvider.getUserInfo();
});
});

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit a8804a9

Please sign in to comment.