{"id":41489249,"url":"https://github.com/eggjs/egg-dubbo-rpc","last_synced_at":"2026-01-23T18:16:27.857Z","repository":{"id":46740132,"uuid":"155833611","full_name":"eggjs/egg-dubbo-rpc","owner":"eggjs","description":"dubbo rpc plugin for egg","archived":false,"fork":false,"pushed_at":"2021-09-28T03:43:05.000Z","size":42,"stargazers_count":40,"open_issues_count":3,"forks_count":2,"subscribers_count":32,"default_branch":"master","last_synced_at":"2025-10-07T18:43:59.140Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eggjs.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-02T08:05:24.000Z","updated_at":"2024-09-10T14:59:00.000Z","dependencies_parsed_at":"2022-09-19T10:50:40.544Z","dependency_job_id":null,"html_url":"https://github.com/eggjs/egg-dubbo-rpc","commit_stats":null,"previous_names":["dubbo/egg-rpc-for-apache-dubbo"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/eggjs/egg-dubbo-rpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fegg-dubbo-rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fegg-dubbo-rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fegg-dubbo-rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fegg-dubbo-rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eggjs","download_url":"https://codeload.github.com/eggjs/egg-dubbo-rpc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eggjs%2Fegg-dubbo-rpc/sbom","scorecard":{"id":358923,"data":{"date":"2025-08-11","repo":{"name":"github.com/eggjs/egg-dubbo-rpc","commit":"f1f1c9b683ecd08b3742cf55721f101a1c4da8dc"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.5,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 1/13 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":6,"reason":"binaries present in source code","details":["Warn: binary detected: test/fixtures/apps/dubbo-nacos/assembly/dubbo-demo-api-1.0-SNAPSHOT-sources.jar:1","Warn: binary detected: test/fixtures/apps/dubbo-nacos/assembly/dubbo-demo-api-1.0-SNAPSHOT.jar:1","Warn: binary detected: test/fixtures/apps/dubbo-rpc-test/assembly/dubbo-demo-api-1.0-SNAPSHOT-sources.jar:1","Warn: binary detected: test/fixtures/apps/dubbo-rpc-test/assembly/dubbo-demo-api-1.0-SNAPSHOT.jar:1"],"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 12 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T10:17:56.704Z","repository_id":46740132,"created_at":"2025-08-18T10:17:56.704Z","updated_at":"2025-08-18T10:17:56.704Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28697428,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T17:25:48.045Z","status":"ssl_error","status_checked_at":"2026-01-23T17:25:47.153Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-23T18:16:24.901Z","updated_at":"2026-01-23T18:16:27.850Z","avatar_url":"https://github.com/eggjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# egg-dubbo-rpc\n\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![David deps][david-image]][david-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/egg-dubbo-rpc.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/egg-dubbo-rpc\n[travis-image]: https://img.shields.io/travis/eggjs/egg-dubbo-rpc.svg?style=flat-square\n[travis-url]: https://travis-ci.org/eggjs/egg-dubbo-rpc\n[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-dubbo-rpc.svg?style=flat-square\n[codecov-url]: https://codecov.io/github/eggjs/egg-dubbo-rpc?branch=master\n[david-image]: https://img.shields.io/david/eggjs/egg-dubbo-rpc.svg?style=flat-square\n[david-url]: https://david-dm.org/eggjs/egg-dubbo-rpc\n[snyk-image]: https://snyk.io/test/npm/egg-dubbo-rpc/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/egg-dubbo-rpc\n[download-image]: https://img.shields.io/npm/dm/egg-dubbo-rpc.svg?style=flat-square\n[download-url]: https://npmjs.org/package/egg-dubbo-rpc\n\nDubbo RPC plugin for Egg.js\n\n## Install\n\n```bash\n$ npm i egg-dubbo-rpc --save\n```\n\n## Usage\n\n### 1. Enable the Plugin\n\nenable egg-dubbo-rpc plugin in ${app_root}/config/plugin.js:\n\n```js\n// {app_root}/config/plugin.js\nexports.dubboRpc = {\n  enable: true,\n  package: 'egg-dubbo-rpc',\n};\n```\n\n### 2. Configuration\n\n```js\n// @example\nexports.rpc = {\n  registry: {\n    address: '127.0.0.1:2181', // configure your real zk address\n  },\n  client: {\n    responseTimeout: 3000,\n  },\n  server: {\n    namespace: 'org.eggjs.rpc.test',\n    port: 12200,\n    maxIdleTime: 90 * 1000,\n    codecType: 'hessian2',\n    selfPublish: true,\n    version: '1.0.0',\n    group: 'DUBBO',\n    autoServe: true,\n  },\n};\n```\n\nall configuations is under `rpc` property\n\n- **registry** (we use zookeeper as service registry in dubbo)\n  - `address:(required)` the zookeeper address\n- **client**\n  - `responseTimeout:(optional)` number of milliseconds to wait for a response, if timeout will get an exception, the default value is 3000(ms)\n- **server**\n  - `namespace:(required)` the default namespace to publish all services\n  - `port:(optional)` the port which RPC server listening on, the default value is 12200\n  - `maxIdleTime:(optional)` maximum idle time (in milliseconds) for a connection\n  - `codecType:(optional)` the serialization type, default value is hessian2\n  - `selfPublish:(optional)` if set to true (default), every worker process will listen on different ports\n  - `version:(optional)` the service version, default value is 1.0.0\n  - `group:(optional)` the service group, default value is DUBBO\n  - `autoServe:(optional)` if set to true (default), will launce Dubbo RPC server automatically\n\n### 3. Call Dubbo Services as Consumer\n\n#### Configure the Interface in proxy.js\n\nFirst, you need to put the JAR file (which contains the API interfaces) into `{app_root}/assembly` folder.\n\nAnd then you need to config `$app_root/config/proxy.js`, which is a very important config file for RPC client, you should configure the services you needed, then executing the egg-rpc-generator tool to generate the proxy files.\n\nLet's see a simple example of proxy.js. It declare a interface named: `org.eggjs.dubbo.UserService` provided by `dubbo` application\n\n```js\n'use strict';\n\nmodule.exports = {\n  group: 'HSF',\n  version: '1.0.0',\n  services: [{\n    appName: 'dubbo',\n    api: {\n      UserService: {\n        interfaceName: 'org.eggjs.dubbo.UserService',\n      },\n    },\n    dependency: [{\n      groupId: 'eggjs',\n      artifactId: 'dubbo-demo-api',\n      version: '1.0-SNAPSHOT',\n    }],\n  }],\n};\n```\n\ndetails as follows:\n\n- `version:(optional)` service version, the global config\n- `group:(optional)` service group\n- `errorAsNull:(optional)` if set true, we are returning null instead of throwing an exception while error appears\n- `services:(required)` RPC services configuation\n  - `appName:(required)` the name of RPC provider\n  - `api:(required)` API details\n    - `interfaceName:(required)` interface name\n    - `version:(optional)` service version, it will overwrite the global one\n    - `group:(optional)` service group, it will overwrite the global one\n  - `dependency:(required)` like Maven pom config\n    - `groupId:(required)` uniquely identifies your project across all projects\n    - `artifactId:(required)` the name of the jar without version\n    - `version:(required)` the jar version\n\n#### Generate the Proxy\n\nRun egg-rpc-generator to generate the proxy files. After running success, it will generate all proxy files under ${app_root}/app/proxy\n\ninstall egg-rpc-generator\n```bash\n$ npm i egg-rpc-generator --save-dev\n```\n\nadd rpc command into scripts of package.json\n\n```json\n{\n  \"scripts\": {\n    \"rpc\": \"egg-rpc-generator\"\n  },\n}\n```\n\nexecute the rpc command\n```bash\n$ npm run rpc\n```\n\n#### Call Dubbo Service\n\nYou can call the Dubbo RPC service by using `ctx.proxy.proxyName`. The proxyName is key value of api object you configure in proxy.js. In our example, it's `UserService`, and proxyName using lower camelcase, so it's `ctx.proxy.userService`\n\n```js\n'use strict';\n\nconst Controller = require('egg').Controller;\n\nclass HomeController extends Controller {\n  async index() {\n    const { ctx } = this;\n    const result = await ctx.proxy.userService.echoUser({\n      id: 123456,\n      name: 'gxcsoccer',\n      address: 'Space C',\n      salary: 100000000,\n    });\n    ctx.body = result;\n  }\n}\n\nmodule.exports = HomeController;\n```\n\n#### Unittest of RPC Client in Egg.js\n\nyou can use `app.mockProxy` to mock the RPC interface\n```js\n'use strict';\n\nconst mm = require('egg-mock');\nconst assert = require('assert');\n\ndescribe('test/mock.test.js', () =\u003e {\n  let app;\n  before(async function() {\n    app = mm.app({\n      baseDir: 'apps/mock',\n    });\n    await app.ready();\n  });\n  afterEach(mm.restore);\n  after(async function() {\n    await app.close();\n  });\n\n  it('should app.mockProxy ok', async function() {\n    app.mockProxy('DemoService', 'sayHello', async function(name) {\n      return 'hello ' + name + ' from mock';\n    });\n\n    const ctx = app.createAnonymousContext();\n    const res = await ctx.proxy.demoService.sayHello('gxcsoccer');\n    assert(res === 'hello gxcsoccer from mock');\n  });\n});\n```\n\nAs above, you can call remote service as a local method.\n\n### 4. Expose Dubbo Services as Provider\n\n#### Define the RPC Interface\n\ncreate a JAR file that contains the API interface\n\n#### Implemenation the RPC Interface\n\nPut your implementation code under `${app_root}/app/rpc` folder\n\n```js\n// ${app_root}/app/rpc/UserService.js\nexports.echoUser = async function(user) {\n  return user;\n};\n\nexports.interfaceName = 'org.eggjs.dubbo.UserService';\nexports.version = '1.0.0';\nexports.group = 'DUBBO';\n```\n\n#### Unittest of your RPC Server in Egg.js\n\n```js\n'use strict';\n\nconst mm = require('egg-mock');\n\ndescribe('test/index.test.js', () =\u003e {\n  let app;\n  before(async function() {\n    app = mm.app({\n      baseDir: 'apps/rpcserver',\n    });\n    await app.ready();\n  });\n  after(async function() {\n    await app.close();\n  });\n\n  it('should invoke HelloService', done =\u003e {\n    app.rpcRequest('org.eggjs.dubbo.UserService')\n      .invoke('echoUser')\n      .send([{\n        id: 123456,\n        name: 'gxcsoccer',\n        address: 'Space C',\n        salary: 100000000,\n      }])\n      .expect({\n        id: 123456,\n        name: 'gxcsoccer',\n        address: 'Space C',\n        salary: 100000000,\n      }, done);\n  });\n});\n```\n\nFor more details of app.rpcRequest, you can refer to this [acticle](https://github.com/eggjs/egg-sofa-rpc/wiki/%E5%8D%95%E5%85%83%E6%B5%8B%E8%AF%95-RPC-%E6%9C%8D%E5%8A%A1%E7%9A%84%E6%96%B9%E6%B3%95)\n\n## Reference List\n\n- [RPC in Node.js Part One](https://www.yuque.com/egg/nodejs/dklip5)\n- [RPC in Node.js Part Two](https://www.yuque.com/egg/nodejs/mhgl9f)\n- [Cross-Language Interoperability between Egg.js \u0026 Dubbo](https://www.yuque.com/egg/nodejs/kril24)\n- [Custom Service Discovery in Egg.js](https://github.com/eggjs/egg-sofa-rpc/wiki/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%9C%8D%E5%8A%A1%E5%8F%91%E7%8E%B0%E5%AE%9E%E7%8E%B0)\n- [RPC Proxy Configuration in Egg.js](https://github.com/eggjs/egg-sofa-rpc/wiki/RPC-%E4%BB%A3%E7%90%86%EF%BC%88Proxy%EF%BC%89%E9%85%8D%E7%BD%AE)\n- [RPC Unittest in Egg.js](https://github.com/eggjs/egg-sofa-rpc/wiki/%E5%8D%95%E5%85%83%E6%B5%8B%E8%AF%95-RPC-%E6%9C%8D%E5%8A%A1%E7%9A%84%E6%96%B9%E6%B3%95)\n\n## Questions \u0026 Suggestions\n\nPlease open an issue [here](https://github.com/dubbo/egg-rpc-for-apache-dubbo/issues).\n\n## License\n\n[Apache License V2](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feggjs%2Fegg-dubbo-rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feggjs%2Fegg-dubbo-rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feggjs%2Fegg-dubbo-rpc/lists"}