{"id":47458,"library":"egg-etcd-grpc","title":"egg-etcd-grpc","description":"An Egg.js plugin that provides gRPC client integration with etcd for service discovery. It enables Egg.js applications to dynamically resolve gRPC service endpoints from etcd, load .proto files, and make gRPC calls. Version 1.0.8, released as needed on GitHub. Differentiates by tight integration with Egg.js lifecycle and configuration patterns, supporting multiple gRPC services per app with auto-reconnection. Requires Node >=16.","status":"active","version":"1.0.8","language":"javascript","source_language":"en","source_url":"https://github.com/lihuanwz/egg-etcd-grpc","tags":["javascript","egg","eggPlugin","egg-plugin","etcd","grpc-client"],"install":[{"cmd":"npm install egg-etcd-grpc","lang":"bash","label":"npm"},{"cmd":"yarn add egg-etcd-grpc","lang":"bash","label":"yarn"},{"cmd":"pnpm add egg-etcd-grpc","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin expects Egg.js application context and lifecycle hooks.","package":"egg","optional":false},{"reason":"Core gRPC library for making client calls.","package":"grpc","optional":false}],"imports":[{"note":"Egg.js plugins are loaded via plugin config, not direct import. The package name is used in plugin.js.","wrong":"require('egg-etcd-grpc') // CommonJS require is not used; plugin is loaded via Egg.js config.","symbol":"egg-etcd-grpc","correct":"// In config/plugin.js:\nexports.etcdGrpc = { enable: true, package: 'egg-etcd-grpc' };"},{"note":"Service names follow proto package hierarchy with dots; access using dot notation on the grpcClient object.","wrong":"app.grpcClient['demoRpc']['passport.profile']['ProfileService'].getUserInfo(...) // Incorrect path: dots are not segmented.","symbol":"app.grpcClient","correct":"app.grpcClient.demoRpc.passport.profile.ProfileService.getUserInfo({userId: '...'})"},{"note":"Configuration is added as property on exports object per Egg.js convention.","wrong":"module.exports = { etcdGrpc: { ... } } // Egg uses exports.* pattern, not module.exports.","symbol":"exports.etcdGrpc","correct":"// In config/config.default.js:\nexports.etcdGrpc = { ... };"}],"quickstart":{"code":"// {app_root}/config/plugin.js\nexports.etcdGrpc = {\n  enable: true,\n  package: 'egg-etcd-grpc',\n};\n\n// {app_root}/config/config.default.js\nexports.etcdGrpc = {\n  demoRpc: {\n    etcd: {\n      hosts: [process.env.ETCD_HOSTS ?? '127.0.0.1:2379'],\n      key: \"demo.rpc\",\n      auth: {\n        username: process.env.ETCD_USERNAME ?? '',\n        password: process.env.ETCD_PASSWORD ?? '',\n      }\n    },\n    grpc: {\n      loaderOption: {\n        keepCase: true,\n        longs: String,\n        enums: String,\n        defaults: true,\n        oneofs: true\n      },\n      protoPath: 'app/grpc/demo',\n      deadline: 1000,\n    }\n  }\n};\n\n// In a controller:\nclass HomeController extends Controller {\n  async index() {\n    const ctx = this.ctx;\n    const userInfo = await ctx.app.grpcClient.demoRpc.passport.profile.ProfileService.getUserInfo({\n      userId: '230371e2-eb07-4b2b-aa61-73fd27c5387e'\n    });\n    ctx.body = userInfo;\n  }\n}","lang":"javascript","description":"Activates the Egg.js plugin, configures a gRPC client with etcd service discovery, and makes a gRPC call from a controller."},"warnings":[{"fix":"Ensure the etcd key in config matches the key used by the gRPC server when registering its endpoint.","message":"Service discovery relies on etcd key being exactly as registered by the server. Mismatched keys cause 'no such service' errors.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"If possible, switch to a package that uses @grpc/grpc-js, or ensure your environment supports native modules.","message":"The plugin uses the `grpc` npm package (gRPC C-core), not `@grpc/grpc-js`. This may cause compatibility issues in some environments (e.g., Alpine Linux) and is slower to install.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Change `loaderOption.longs` to `Number` or use a custom function if you need JavaScript Number (with precision loss) or keep as Long object.","message":"The `loaderOption.longs` is set to `String` by default, which converts Long types to strings. If you need numeric operations on long values, this will cause silent failures or type errors.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Set deadline to at least 10,000 ms for typical RPCs, or adjust based on your service latency.","message":"The `deadline` option is in milliseconds, not seconds. Setting it too low may cause frequent DEADLINE_EXCEEDED errors.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'1.0.8':38 '16':66 'app':59 'applic':21 'auto':62 'auto-reconnect':61 'call':36 'client':11,76 'configur':52 'differenti':44 'discoveri':17 'dynam':23 'egg':2,68,71 'egg-etcd-grpc':1 'egg-plugin':70 'egg.js':6,20,49 'eggplugin':69 'enabl':19 'endpoint':27 'etcd':3,14,29,73 'file':32 'github':43 'grpc':4,10,25,35,56,75 'grpc-client':74 'integr':12,47 'javascript':67 'lifecycl':50 'load':30 'make':34 'multipl':55 'need':41 'node':65 'pattern':53 'per':58 'plugin':7,72 'proto':31 'provid':9 'reconnect':63 'releas':39 'requir':64 'resolv':24 'servic':16,26,57 'support':54 'tight':46 'version':37","created_at":"2026-06-07T16:51:37.278151+00:00","updated_at":"2026-06-07T16:51:37.278151+00:00","problems":[{"fix":"Run `npm install egg-etcd-grpc --save` in your project root.","cause":"Plugin not installed via npm.","error":"Error: Cannot find module 'egg-etcd-grpc'"},{"fix":"Ensure `config.etcdGrpc.grpc.protoPath` points to a directory containing the .proto files, and the service name in the gRPC call matches exactly (including package).","cause":"The proto file path or service name does not match config.","error":"Error: Can not find service in proto files"},{"fix":"Verify the service registered in etcd with the same `key` value as in config.etcdGrpc.etcd.key.","cause":"The etcd key does not match the registered gRPC service endpoint.","error":"Error: No such service: <service>"},{"fix":"Check that `config/plugin.js` has `exports.etcdGrpc = { enable: true, package: 'egg-etcd-grpc' };` and `config/config.default.js` has `exports.etcdGrpc = { ... };` properly set.","cause":"Plugin is not enabled or configuration is incorrect.","error":"TypeError: app.grpcClient.demoRpc is undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/lihuanwz/egg-etcd-grpc#readme","github":"https://github.com/lihuanwz/egg-etcd-grpc","docs":null,"changelog":null,"pypi":null,"npm":"egg-etcd-grpc","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}