mirror of
https://github.com/sofastack/sofa-rpc-node.git
synced 2025-12-08 20:26:00 +00:00
* fix: grpc invoke multi times same response * fix: close grpc connection when service throw exception * fix: grpc callStream leak * fix: grpc response error
34 lines
628 B
JavaScript
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();
|