gRPC framework for egg
Features
- Support gRPC + Protobuf
- Extend EGG Router To Support RPC Method
- It Supports EGG Middleware、Plugin
- It Supports Both HTTP、gRPC Request,Common Use Controller And Service
QuickStart
$ npm install egg-obelisk --save
Usage
// package.json
Configuration
// {app_root}/config/config.default.jsconfigobelisk = // listen: false, // disable gRPCServer listen: port: 50051 hostname: '0.0.0.0' // protoLoader: { // options: { keepCase: true, longs: String, enums: String, defaults: true, oneofs: true }, // }, // gRPCServerOptions: {},;
Example
// {app_root}/app/router.js'use strict'; module { const router controller = app; router; router;};
// {app_root}/app/controller/user.js'use strict'; const Controller = Controller; async { const body = thisctxrequestbody; const result = await thisserviceuser; thisctxbody = result; } // test http method call rpc async { const params = thisctxquery; const result = await thisctxrpcuserServiceuser; thisctxbody = result; } moduleexports = UserController;
// {app_root}/app/service/user.js'use strict'; const Service = Service; async { // ... return state: 'ok' ; } moduleexports = UserService;
$ curl http://localhost:7001/rpc?username=admin&password=xxx