├── .autod.conf.js ├── .eslintignore ├── .eslintrc ├── .github ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .travis.yml ├── History.md ├── LICENSE ├── README.md ├── app └── extend │ └── application.js ├── config ├── config.default.js └── plugin.js ├── index.js ├── lib ├── core │ └── base_service.js ├── framework.js └── util │ └── index.js ├── package.json └── test ├── dubbo-rpc.test.js ├── fixtures └── apps │ ├── dubbo-rpc-test │ ├── app │ │ ├── controller │ │ │ └── home.js │ │ ├── proxy │ │ │ └── demoService.js │ │ ├── proxy_class │ │ │ ├── eggjs │ │ │ │ └── demo │ │ │ │ │ └── Person.js │ │ │ └── index.js │ │ ├── router.js │ │ └── rpc │ │ │ └── DemoService.js │ ├── assembly │ │ ├── dubbo-demo-api-1.0-SNAPSHOT-sources.jar │ │ └── dubbo-demo-api-1.0-SNAPSHOT.jar │ ├── config │ │ ├── config.default.js │ │ ├── plugin.js │ │ └── proxy.js │ └── package.json │ └── healthy │ └── package.json ├── healthy.test.js └── init.sh /.autod.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | write: true, 5 | prefix: '^', 6 | plugin: 'autod-egg', 7 | test: [ 8 | 'test', 9 | 'benchmark', 10 | ], 11 | dep: [ 12 | 'egg' 13 | ], 14 | devdep: [ 15 | 'egg-bin', 16 | 'autod', 17 | 'eslint', 18 | 'eslint-config-egg', 19 | 'egg-rpc-generator', 20 | 'webstorm-disable-index', 21 | ], 22 | exclude: [ 23 | './test/fixtures', 24 | './dist', 25 | ], 26 | }; 27 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | test/fixtures 2 | coverage 3 | examples/**/app/public 4 | logs 5 | run 6 | zookeeper-3.4.6/ 7 | coverage 8 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "eslint-config-egg" 3 | } 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 18 | 19 | * **Node Version**: 20 | * **Egg Version**: 21 | * **Plugin Name**: 22 | * **Plugin Version**: 23 | * **Platform**: 24 | * **Mini Showcase Repository**: 25 | 26 | 27 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 10 | 11 | ##### Checklist 12 | 13 | 14 | - [ ] `npm test` passes 15 | - [ ] tests and/or benchmarks are included 16 | - [ ] documentation is changed or added 17 | - [ ] commit message follows commit guidelines 18 | 19 | ##### Affected core subsystem(s) 20 | 21 | 22 | 23 | ##### Description of change 24 | 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # next.js build output 61 | .next 62 | 63 | .* 64 | !.github 65 | !.eslintignore 66 | !.eslintrc 67 | !.gitignore 68 | !.travis.yml 69 | !.autod.conf.js 70 | *.bin 71 | 72 | run 73 | test/fixtures/apps/**/proxy 74 | test/fixtures/apps/**/proxy_class 75 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - '8' 5 | - '10' 6 | before_install: 7 | - 'wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz' 8 | - 'tar xf zookeeper-3.4.6.tar.gz' 9 | - 'mv zookeeper-3.4.6/conf/zoo_sample.cfg zookeeper-3.4.6/conf/zoo.cfg' 10 | - './zookeeper-3.4.6/bin/zkServer.sh start' 11 | install: 12 | - npm i npminstall && npminstall --registry=https://registry.npm.taobao.org 13 | script: 14 | - npm run ci 15 | after_script: 16 | - npminstall codecov && codecov 17 | -------------------------------------------------------------------------------- /History.md: -------------------------------------------------------------------------------- 1 | 2 | 0.2.0 / 2018-11-30 3 | ================== 4 | 5 | **features** 6 | * [[`22a291a`](http://github.com/eggjs/egg-cloud/commit/22a291aadbd1e22a1f1adf5eb61425bc694e6dae)] - feat: add egg-dubbo-tracer (gxcsoccer <>) 7 | 8 | 0.1.0 / 2018-11-16 9 | ================== 10 | 11 | **features** 12 | * [[`1fe078c`](http://github.com/eggjs/egg-cloud/commit/1fe078c351d4cfaea85beca84690e3592367c6c4)] - feat: add egg-healthy (popomore <>) 13 | 14 | 0.0.2 / 2018-11-03 15 | ================== 16 | 17 | **others** 18 | * [[`39c5c4c`](http://github.com/eggjs/egg-cloud/commit/39c5c4ce7b3d7a3e5da807d8f167a651f58034f9)] - refactor: support dubbo rpc (gxcsoccer <>) 19 | * [[`8a40b89`](http://github.com/eggjs/egg-cloud/commit/8a40b897657fe4fbd1ec88dfe57650bf163b3955)] - chore: ignore nyc_output folder (gxcsoccer <>) 20 | * [[`cdfc1a3`](http://github.com/eggjs/egg-cloud/commit/cdfc1a30fee7df3eb8fafa3d76ec4d0722c30326)] - chore: fix HISTORY.md (gxcsoccer <>) 21 | 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 eggjs core team and other contributors. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # egg cloud 2 | 3 | egg cloud provider tools for developers to quickly build some of the common patterns in distributed systems 4 | 5 | [![NPM version][npm-image]][npm-url] 6 | [![build status][travis-image]][travis-url] 7 | [![Test coverage][codecov-image]][codecov-url] 8 | [![David deps][david-image]][david-url] 9 | [![Known Vulnerabilities][snyk-image]][snyk-url] 10 | [![npm download][download-image]][download-url] 11 | 12 | [npm-image]: https://img.shields.io/npm/v/egg-cloud.svg?style=flat-square 13 | [npm-url]: https://npmjs.org/package/egg-cloud 14 | [travis-image]: https://img.shields.io/travis/eggjs/egg-cloud.svg?style=flat-square 15 | [travis-url]: https://travis-ci.org/eggjs/egg-cloud 16 | [codecov-image]: https://codecov.io/gh/eggjs/egg-cloud/branch/master/graph/badge.svg 17 | [codecov-url]: https://codecov.io/gh/eggjs/egg-cloud 18 | [david-image]: https://img.shields.io/david/eggjs/egg-cloud.svg?style=flat-square 19 | [david-url]: https://david-dm.org/eggjs/egg-cloud 20 | [snyk-image]: https://snyk.io/test/npm/egg-cloud/badge.svg?style=flat-square 21 | [snyk-url]: https://snyk.io/test/npm/egg-cloud 22 | [download-image]: https://img.shields.io/npm/dm/egg-cloud.svg?style=flat-square 23 | [download-url]: https://npmjs.org/package/egg-cloud 24 | 25 | ## QuickStart 26 | 27 | [here](https://www.katacoda.com/gxcsoccer/scenarios/all-in-one) is a quick start tutorial 28 | 29 | ## Documentation 30 | 31 | :construction: coming soom 32 | 33 | ## Questions & Suggestions 34 | 35 | Please open an issue [here](https://github.com/eggjs/egg/issues). 36 | 37 | ## License 38 | 39 | [MIT](https://github.com/eggjs/egg-cloud/blob/master/LICENSE) 40 | -------------------------------------------------------------------------------- /app/extend/application.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Service = require('../../lib/core/base_service'); 4 | 5 | module.exports = { 6 | /** 7 | * Service 基类 8 | * @member {Service} Application#Service 9 | * @since 1.0.0 10 | */ 11 | Service, 12 | }; 13 | -------------------------------------------------------------------------------- /config/config.default.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const utils = require('../lib/util'); 4 | 5 | module.exports = appInfo => ({ 6 | keys: utils.createAppKeys(appInfo.name), 7 | }); 8 | -------------------------------------------------------------------------------- /config/plugin.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | exports.rpc = { 4 | enable: true, 5 | package: 'egg-rpc-base', 6 | }; 7 | 8 | exports.dubboRpc = { 9 | enable: true, 10 | package: 'egg-dubbo-rpc', 11 | }; 12 | 13 | exports.dubboTracer = { 14 | enable: true, 15 | package: 'egg-dubbo-tracer', 16 | }; 17 | 18 | exports.opentracing = { 19 | enable: true, 20 | package: 'egg-opentracing', 21 | }; 22 | 23 | exports.zipkin = { 24 | enable: false, 25 | package: 'egg-opentracing-zipkin', 26 | }; 27 | 28 | exports.prometheus = { 29 | enable: false, 30 | package: 'egg-prometheus', 31 | }; 32 | 33 | exports.healthy = { 34 | enable: true, 35 | package: 'egg-healthy', 36 | }; 37 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = require('./lib/framework.js'); 4 | -------------------------------------------------------------------------------- /lib/core/base_service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const EggService = require('egg').Service; 4 | 5 | /** 6 | * service 基类,封装 service 的通用逻辑。 7 | * 你可以通过继承此基类来编写 service 8 | * @example 9 | * ```js 10 | * // app/service/user.js 11 | * const Service = require('sofa-node').Service; 12 | * 13 | * class User extends Service { 14 | * constructor(ctx) { 15 | * super(ctx); 16 | * // 你的业务逻辑 17 | * } 18 | * 19 | * * findUser(uid) { 20 | * uid = Number(uid); 21 | * if (!uid) { 22 | * return null; 23 | * } 24 | * return await this.proxy.userQuery.findUser(uid); 25 | * } 26 | * 27 | * // 更多其他方法 28 | * } 29 | * ``` 30 | */ 31 | class Service extends EggService { 32 | 33 | constructor(ctx) { 34 | super(ctx); 35 | this.className = this.pathName; 36 | } 37 | 38 | /** 39 | * @member {Proxy} 40 | */ 41 | get proxy() { 42 | return this.ctx.proxy; 43 | } 44 | 45 | } 46 | 47 | module.exports = Service; 48 | -------------------------------------------------------------------------------- /lib/framework.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const path = require('path'); 4 | const egg = require('egg'); 5 | const EGG_PATH = Symbol.for('egg#eggPath'); 6 | const Service = require('./core/base_service'); 7 | 8 | class Application extends egg.Application { 9 | get [EGG_PATH]() { 10 | return path.dirname(__dirname); 11 | } 12 | } 13 | 14 | class Agent extends egg.Agent { 15 | get [EGG_PATH]() { 16 | return path.dirname(__dirname); 17 | } 18 | } 19 | 20 | module.exports = Object.assign(egg, { 21 | Application, 22 | Agent, 23 | Service, 24 | }); 25 | -------------------------------------------------------------------------------- /lib/util/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const utility = require('utility'); 4 | 5 | // 生成一个稳定的唯一的 app key 6 | exports.createAppKeys = function(appname) { 7 | return utility.md5(utility.sha1(utility.md5(utility.sha1(appname + '.keys')))) + '.' + appname; 8 | }; 9 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "egg-cloud", 3 | "version": "0.2.0", 4 | "description": "A microservices framework for Node.js", 5 | "main": "index.js", 6 | "dependencies": { 7 | "egg": "^2.14.1", 8 | "egg-dubbo-rpc": "^1.0.0", 9 | "egg-dubbo-tracer": "^1.0.0", 10 | "egg-healthy": "^1.0.0", 11 | "egg-opentracing": "^1.1.1", 12 | "egg-opentracing-zipkin": "^1.0.0", 13 | "egg-prometheus": "^1.0.2", 14 | "egg-rpc-base": "^1.3.0", 15 | "utility": "^1.15.0" 16 | }, 17 | "devDependencies": { 18 | "autod": "^3.0.1", 19 | "autod-egg": "^1.0.0", 20 | "egg-bin": "^4.9.0", 21 | "egg-mock": "^3.20.1", 22 | "egg-rpc-generator": "^1.1.1", 23 | "eslint": "^5.9.0", 24 | "eslint-config-egg": "^7.1.0", 25 | "mz-modules": "^2.1.0", 26 | "webstorm-disable-index": "^1.2.0" 27 | }, 28 | "engines": { 29 | "node": ">=8.0.0" 30 | }, 31 | "scripts": { 32 | "test": "npm run lint -- --fix && egg-bin pkgfiles && npm run test-local", 33 | "test-local": "egg-bin test", 34 | "cov": "sh test/init.sh && egg-bin cov", 35 | "lint": "eslint .", 36 | "ci": "npm run autod -- --check && npm run lint && egg-bin pkgfiles --check && npm run cov", 37 | "autod": "autod", 38 | "pkgfiles": "egg-bin pkgfiles" 39 | }, 40 | "ci": { 41 | "version": "8, 10" 42 | }, 43 | "repository": { 44 | "type": "git", 45 | "url": "" 46 | }, 47 | "keywords": [ 48 | "egg", 49 | "egg-cloud", 50 | "egg-framework" 51 | ], 52 | "author": "gxcsoccer ", 53 | "files": [ 54 | "index.js", 55 | "lib", 56 | "app", 57 | "config" 58 | ], 59 | "eslintIgnore": [ 60 | "coverage", 61 | "dist" 62 | ], 63 | "license": "MIT" 64 | } 65 | -------------------------------------------------------------------------------- /test/dubbo-rpc.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const path = require('path'); 5 | const mock = require('egg-mock'); 6 | const assert = require('assert'); 7 | const sleep = require('mz-modules/sleep'); 8 | 9 | describe('test/dubbo-rpc.test.js', () => { 10 | let app; 11 | before(async function() { 12 | app = mock.app({ 13 | baseDir: 'apps/dubbo-rpc-test', 14 | framework: true, 15 | }); 16 | await app.ready(); 17 | await sleep(2000); 18 | }); 19 | 20 | after(() => app.close()); 21 | afterEach(mock.restore); 22 | 23 | it('should invoke dubbo rpc ok', () => { 24 | return app.httpRequest() 25 | .get('/') 26 | .expect('hello gxcsoccer') 27 | .expect(200); 28 | }); 29 | 30 | it('should invoke echoPerson', async function() { 31 | await app.rpcRequest('eggjs.demo.DemoService') 32 | .invoke('echoPerson') 33 | .send([{ 34 | name: '宗羽', 35 | address: 'C 空间', 36 | id: 68955, 37 | salary: 10000000, 38 | }]) 39 | .expect({ 40 | name: '宗羽', 41 | address: 'C 空间', 42 | id: 68955, 43 | salary: 10000000, 44 | }); 45 | 46 | const data = fs.readFileSync(path.join(app.config.baseDir, 'logs/dubbo-rpc-test/opentracing.log'), 'utf8'); 47 | const spans = data.trim().split('\n').map(item => { 48 | return JSON.parse(item); 49 | }); 50 | assert(spans && spans.length === 4); 51 | }); 52 | }); 53 | -------------------------------------------------------------------------------- /test/fixtures/apps/dubbo-rpc-test/app/controller/home.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Controller = require('egg').Controller; 4 | 5 | class HomeController extends Controller { 6 | async index() { 7 | this.ctx.body = await this.ctx.proxy.demoService.sayHello('gxcsoccer'); 8 | } 9 | } 10 | 11 | module.exports = HomeController; 12 | -------------------------------------------------------------------------------- /test/fixtures/apps/dubbo-rpc-test/app/proxy/demoService.js: -------------------------------------------------------------------------------- 1 | // Don't modified this file, it's auto created by jar2proxy 2 | 3 | 'use strict'; 4 | 5 | const path = require('path'); 6 | 7 | /* eslint-disable */ 8 | /* istanbul ignore next */ 9 | module.exports = function (app) { 10 | const appName = 'jar2proxy'; 11 | let version = '1.0.0'; 12 | if (app.config.proxy && app.config.proxy.envVersion) { 13 | version = app.config.proxy.envVersion[appName] || version; 14 | } 15 | const rpcClient = app.rpcClient; 16 | if (!rpcClient) return; 17 | const consumer = rpcClient.createConsumer({ 18 | interfaceName: 'eggjs.demo.DemoService', 19 | version, 20 | targetAppName: appName, 21 | group: 'HSF', 22 | proxyName: 'demoService', 23 | responseTimeout: 3000, 24 | }); 25 | 26 | 27 | class DemoService extends app.Proxy { 28 | constructor(ctx) { 29 | super(ctx, consumer); 30 | } 31 | 32 | // java source code: String sayHello(String name); 33 | // returnType: java.lang.String 34 | async sayHello(name) { 35 | const args = [ 36 | { 37 | $class: 'java.lang.String', 38 | $: name, 39 | } 40 | ]; 41 | return await consumer.invoke('sayHello', args, { 42 | ctx: this.ctx, 43 | }); 44 | } 45 | 46 | // java source code: Person echoPerson(Person p); 47 | // returnType: eggjs.demo.Person 48 | async echoPerson(p) { 49 | const args = [ 50 | { 51 | $class: 'eggjs.demo.Person', 52 | $: p, 53 | } 54 | ]; 55 | return await consumer.invoke('echoPerson', args, { 56 | ctx: this.ctx, 57 | }); 58 | } 59 | } 60 | return DemoService; 61 | }; 62 | 63 | /* eslint-enable */ 64 | 65 | -------------------------------------------------------------------------------- /test/fixtures/apps/dubbo-rpc-test/app/proxy_class/eggjs/demo/Person.js: -------------------------------------------------------------------------------- 1 | // Don't modified this file, it's auto created by jar2proxy 2 | 3 | 'use strict'; 4 | 5 | /* eslint-disable */ 6 | /* jshint ignore:start */ 7 | module.exports = { 8 | 'eggjs.demo.Person': { 9 | 'id': { 10 | 'type': 'int', 11 | 'defaultValue': 0, 12 | }, 13 | 'name': { 14 | 'type': 'java.lang.String', 15 | }, 16 | 'address': { 17 | 'type': 'java.lang.String', 18 | }, 19 | 'salary': { 20 | 'type': 'int', 21 | 'defaultValue': 0, 22 | }, 23 | }, 24 | }; 25 | /* jshint ignore:end */ 26 | /* eslint-enable */ 27 | -------------------------------------------------------------------------------- /test/fixtures/apps/dubbo-rpc-test/app/proxy_class/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const path = require('path'); 5 | 6 | const classMap = {}; 7 | 8 | module.exports = className => { 9 | let map = classMap[className]; 10 | if (!map) { 11 | const args = className.split('.'); 12 | args.unshift(this.proxyClassDir); 13 | args[ args.length - 1 ] = args[ args.length - 1 ] + '.js'; 14 | const classfile = path.join.apply(null, args); 15 | if (fs.existsSync(classfile)) { 16 | map = classMap[className] = require(classfile); 17 | } else { 18 | throw new Error(`class ${classMap} not found.`); 19 | } 20 | } 21 | return map; 22 | }; 23 | -------------------------------------------------------------------------------- /test/fixtures/apps/dubbo-rpc-test/app/router.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = app => { 4 | const { router, controller } = app; 5 | 6 | router.get('/', controller.home.index); 7 | }; 8 | -------------------------------------------------------------------------------- /test/fixtures/apps/dubbo-rpc-test/app/rpc/DemoService.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | exports.sayHello = async function(name) { 4 | return 'hello ' + name; 5 | }; 6 | 7 | exports.echoPerson = async function(p) { 8 | return { 9 | $class: 'eggjs.demo.Person', 10 | $: p, 11 | }; 12 | }; 13 | -------------------------------------------------------------------------------- /test/fixtures/apps/dubbo-rpc-test/assembly/dubbo-demo-api-1.0-SNAPSHOT-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eggjs/egg-cloud/c174aae3cc570b05ea02743611c38334150e1b7d/test/fixtures/apps/dubbo-rpc-test/assembly/dubbo-demo-api-1.0-SNAPSHOT-sources.jar -------------------------------------------------------------------------------- /test/fixtures/apps/dubbo-rpc-test/assembly/dubbo-demo-api-1.0-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eggjs/egg-cloud/c174aae3cc570b05ea02743611c38334150e1b7d/test/fixtures/apps/dubbo-rpc-test/assembly/dubbo-demo-api-1.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /test/fixtures/apps/dubbo-rpc-test/config/config.default.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | exports.keys = '123456'; 4 | 5 | exports.rpc = { 6 | registry: { 7 | address: '127.0.0.1:2181', 8 | }, 9 | server: { 10 | version: '1.0.0', 11 | group: 'HSF', 12 | codecType: 'hessian2', 13 | namespace: 'eggjs.demo', 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /test/fixtures/apps/dubbo-rpc-test/config/plugin.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | -------------------------------------------------------------------------------- /test/fixtures/apps/dubbo-rpc-test/config/proxy.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | group: 'HSF', 5 | version: '1.0.0', 6 | services: [{ 7 | appName: 'jar2proxy', 8 | api: { 9 | DemoService: { 10 | interfaceName: 'eggjs.demo.DemoService', 11 | }, 12 | }, 13 | dependency: [{ 14 | groupId: 'org.apache.dubbo', 15 | artifactId: 'dubbo-demo-api', 16 | version: '1.0-SNAPSHOT', 17 | }], 18 | }], 19 | }; 20 | -------------------------------------------------------------------------------- /test/fixtures/apps/dubbo-rpc-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dubbo-rpc-test", 3 | "version": "0.0.1" 4 | } -------------------------------------------------------------------------------- /test/fixtures/apps/healthy/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "egg-cloud" 3 | } 4 | -------------------------------------------------------------------------------- /test/healthy.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const mock = require('egg-mock'); 4 | 5 | describe('test/healthy.test.js', () => { 6 | let app; 7 | before(() => { 8 | app = mock.app({ 9 | baseDir: 'apps/healthy', 10 | framework: true, 11 | }); 12 | return app.ready(); 13 | }); 14 | after(() => app.close()); 15 | afterEach(mock.restore); 16 | 17 | it('should be healthy', () => { 18 | return app.httpRequest() 19 | .get('/healthy/readiness') 20 | .expect('OK') 21 | .expect(200); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /test/init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | GEN=${PWD}/node_modules/.bin/egg-rpc-generator 4 | 5 | # test dir 6 | 7 | DIR=${PWD}/test/fixtures/apps 8 | NAMES="dubbo-rpc-test" 9 | 10 | for NAME in $NAMES 11 | do 12 | echo "Create ${DIR}/${NAME} proxy" 13 | $GEN -b ${DIR}/${NAME} 14 | echo "------------------------------------------------" 15 | done 16 | 17 | echo "All done" 18 | --------------------------------------------------------------------------------