grpc-client-promise

1.0.5 • Public • Published

grpc-client-promise

grpc-client-promise also support Promise API. Which works very well with ES7 async await.

Installation

npm i grpc-client-promise

Usage

  • grpcClient.conntct(options)

    • options
      • ip: server ip
      • port: server port
      • protosPath: grpc protos folder path
      • ervicesPath: grpc services folder path
    • example
    const client = grpcClient.conntct({
        ip: '127.0.0.1',
        port: 8981,
        protosPath: './test',
        servicesPath: './test'
    });
    
  • client.services.method(requestParams,[metadata])

    • example
    client.greeter.greet({ name: hello }).then(ret => console.log(ret));
    
    client.greeter.greet({ name: hello }, metadata).then(ret => console.log(ret));
    

Demo

'use strict'

const grpcClient = require('../index');

const client = grpcClient.conntct({
    ip: '127.0.0.1',
    port: 8981,
    protosPath: './test',
    servicesPath: './test'
});

client.greeter.greet().then(ret => console.log(ret));

client.greeter.greet({ name: hello }).then(ret => console.log(ret));

const Metadata = grpc.Metadata;
const metadata = new Metadata();
metadata.set('token', '231hjkhdKJH321J4H3KJ12HKJ');
client.greeter.greet({ name: hello }, metadata).then(ret => console.log(ret));

Readme

Keywords

none

Package Sidebar

Install

npm i grpc-client-promise

Weekly Downloads

2

Version

1.0.5

License

ISC

Unpacked Size

4.96 kB

Total Files

6

Last publish

Collaborators

  • flyaway1978