sofa-rpc-node/example/grpc_server.js
zl 2439e1e0dc fix grpc bugs (#40)
* fix: grpc invoke multi times same response
* fix: close grpc connection when service throw exception
* fix: grpc callStream leak
* fix: grpc response error
2019-03-27 02:09:54 +08:00

34 lines
628 B
JavaScript

'use strict';
const protobuf = require('antpb');
const path = require('path');
const proto = protobuf.loadAll(path.join(__dirname, 'proto'));
const logger = console;
const GRpcServer = require('../lib/server/grpc/server');
const server = new GRpcServer({
logger,
port: 12200,
proto,
});
server.addService({
interfaceName: 'helloworld.Greeter',
}, {
async SayHello(req) {
console.log(req);
return {
message: `hello ${req.name} from sofa-rpc-node`,
};
},
async SayHi(req) {
console.log(req);
return {
message: `hi ${req.name} from sofa-rpc-node`,
};
},
});
server.start();