Skip to content
Permalink
Browse files
feat: update koa example
  • Loading branch information
Bill committed Aug 11, 2021
1 parent b6cee5a commit 44f089c977e054f51328e5f05b45a93eb3a68ca7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
@@ -3,14 +3,14 @@
"version": "1.0.0",
"description": "A simple demo",
"scripts": {
"debug:start": "DEBUG=dubbo* ts-node ./src/server-zookeeper.ts",
"debug:start": "cross-env DEBUG=dubbo* ts-node ./src/server-zookeeper.ts",
"start": "ts-node ./src/server-zookeeper.ts",
"dubbo-server": "ts-node ./src/dubbo/provider/server-zookeeper.ts",
"debug:dubbo-server": "DEBUG=dubbo* ts-node ./src/dubbo/provider/server-zookeeper.ts",
"debug:start-nacos": "DEBUG=dubbo* ts-node ./src/server-nacos.ts",
"debug:dubbo-server": "cross-env DEBUG=dubbo* ts-node ./src/dubbo/provider/server-zookeeper.ts",
"debug:start-nacos": "cross-env DEBUG=dubbo* ts-node ./src/server-nacos.ts",
"start-nacos": "ts-node ./src/server-nacos.ts",
"dubbo-server-nacos": "ts-node ./src/dubbo/provider/server-nacos.ts",
"debug:dubbo-server-nacos": "DEBUG=dubbo* ts-node ./src/dubbo/provider/server-nacos.ts"
"debug:dubbo-server-nacos": "cross-env DEBUG=dubbo* ts-node ./src/dubbo/provider/server-nacos.ts"
},
"keywords": [
"apache-dubbo-js"
@@ -19,9 +19,13 @@
"license": "Apache Licence 2.0",
"devDependencies": {
"@types/koa": "^2.11.4",
"@types/koa-router": "^7.4.1"
"@types/koa-router": "^7.4.1",
"cross-env": "^7.0.3"
},
"dependencies": {
"apache-dubbo-consumer": "^4.0.0",
"apache-dubbo-registry": "0.0.2",
"interpret-util": "0.0.6",
"ip": "^1.1.5",
"koa": "^2.4.1",
"koa-router": "^7.3.0"
@@ -15,13 +15,14 @@
* limitations under the License.
*/

import {Dubbo, setting, nacos} from 'apache-dubbo-js'
import * as service from './service'
import { Dubbo, dubboSetting } from 'apache-dubbo-consumer'
import { Nacos } from 'apache-dubbo-registry'
import * as services from './service'

/**
* setting dubbo invoke params, such version, group etc.
*/
const dubboSetting = setting
const setting = dubboSetting
.match(
[
'org.apache.dubbo.demo.DemoProvider',
@@ -31,18 +32,19 @@ const dubboSetting = setting
version: '1.0.0',
},
)
.match('org.apache.dubbo.demo.BasicTypeProvider', {version: '2.0.0'})
.match('org.apache.dubbo.demo.BasicTypeProvider', { version: '2.0.0' })

/**
* create dubbo instance, it create proxyService
*/
// console.log('nacos-----', nacos);
const dubbo = new Dubbo<typeof service>({
application: {name: 'dubbo-node-consumer'},
service,
dubboSetting,
registry: nacos({
url: 'nacos:localhost:8848',
const dubbo = new Dubbo<typeof services>({
application: {
name: 'dubbo-node-consumer'
},
services,
dubboSetting: setting,
registry: Nacos({
connect: 'localhost:8848',
}),
})

@@ -54,13 +56,4 @@ dubbo.use(async (ctx, next) => {
console.log('-providerAttachments-->', ctx.providerAttachments)
})

/**
* subscribe apache-dubbo-js inner message
*/
dubbo.subscribe({
onTrace(msg) {
console.log(msg)
},
})

export default dubbo

0 comments on commit 44f089c

Please sign in to comment.