pull-grpc

1.0.0 • Public • Published

pull-grpc stability

npm version build status test coverage downloads js-standard-style

GRPC pull stream interface.

Usage

const pull = require('pull-stream')
const grpc = require('pull-grpc')

const uri = 'localhost:50051'
const schema = `
  syntax = "proto3";
  package messages;

  service MessageThing {
    rpc EchoHello (stream Sup) returns (stream Sup) {}
  }

  message Sup {
    required string msg = 1;
  }
`

// server: echo each request back as the response
const server = grpc.server(schema, {
  echoHello: (call) => pull(call, call)
})
server.listen(uri, { secure: false })

// client: send the message "hey world" once
const sink = grpc.client(uri, { secure: false }, (err, source) => {
  if (err) throw err
  pull(source, pull.drain(write, end))

  function write (data) {
    console.log(`data: ${data}`)
    // => "data: hey world"
  }

  function end (err) {
    if (err) throw err
    console.log('server done!')
    server.close()
  }
})

pull(pull.once({ msg: 'hey world' }), sink)

API

pullGrpc

Installation

$ npm install pull-grpc

License

MIT

Package Sidebar

Install

npm i pull-grpc

Weekly Downloads

3

Version

1.0.0

License

MIT

Last publish

Collaborators

  • yoshuawuyts