2.1.1 • Published 2 years ago

@rough/rx-grpc v2.1.1

Weekly downloads
6
License
MIT
Repository
github
Last release
2 years ago

The simplest RxJS wrapper around grpc lib

Build Status npm version

Rough implementation of rxified wrapper and tools for grpc-js lib.

Usage example

// GreetingService.proto

syntax = "proto3";

package org.example;

service GreetingService {
  rpc Greet(Request) returns (Response);
}

message Request {
  string name = 1;
}

message Response {
  string message = 1;
}
// server.js

class GreetingService {
  Greet(call, callback) {
    const name = call.request.name;
    if (name)
      callback(null, { message: `Hello, ${name}!` });
    else
      callback(new Error('Name is not defined.'));
  }
}

const RxGrpc = require('@rough/rx-grpc');
new RxGrpc()
  .withProtoFiles(__dirname + '/*.proto')
  .serve('org.example.GreetingService', new GreetingService())
  .startServer()
  .subscribe(
    started => console.log('Listening at grpc://0.0.0.0:50051 ...'),
    err => console.log(err),
    complete => {}
  );
// client.js

const { flatMap } = require('rxjs/operators');
const RxGrpc = require('@rough/rx-grpc');

const rxgrpc = new RxGrpc().withProtoFiles(__dirname + '/*.proto');

const name = (process.argv.length > 2) ? process.argv[2] : null;

rxgrpc.service('org.example.GreetingService', 'localhost:50051').pipe(
  flatMap(GreetingService => GreetingService.Greet({ name }))
)
.subscribe(
  response => console.log(response.message),
  err => console.log(err),
  complete => {}
);
2.1.1

2 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.7.0

5 years ago

1.6.0

5 years ago

1.5.0

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago