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
29 lines
624 B
JavaScript
29 lines
624 B
JavaScript
'use strict';
|
|
|
|
const path = require('path');
|
|
const protobuf = require('antpb');
|
|
const proto = protobuf.loadAll(path.join(__dirname, 'proto'));
|
|
|
|
const logger = console;
|
|
const { GRpcClient } = require('../').client;
|
|
|
|
const client = new GRpcClient({
|
|
logger,
|
|
proto,
|
|
});
|
|
|
|
async function test() {
|
|
const consumer = client.createConsumer({
|
|
interfaceName: 'helloworld.Greeter',
|
|
serverHost: 'http://localhost:12200',
|
|
});
|
|
await consumer.ready();
|
|
const r = await Promise.all([
|
|
consumer.invoke('SayHello', [{ name: 'peter' }]),
|
|
consumer.invoke('SayHi', [{ name: 'tony' }]),
|
|
]);
|
|
console.log(r);
|
|
}
|
|
|
|
test();
|