mirror of
https://github.com/sofastack/sofa-rpc-node.git
synced 2026-01-18 15:55:54 +00:00
26 lines
550 B
JavaScript
26 lines
550 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 consumer.invoke('SayHello', [{ name: 'peter' }]);
|
|
console.log(r);
|
|
}
|
|
|
|
test();
|