pull-pb-rpc
v0.0.4
Published
Protocol Buffers RPC utility module for pull-streams
Downloads
3
Maintainers
Readme
pull-pb-rpc
Protocol Buffers RPC utility module for pull-streams
Usage
const conn = getConnectionSomehow()
const PBRPC = require('pull-pb-rpc')
const pbRPC = PBRPC()
const rpc = pbRPC.rpc
pull(
conn,
pbRPC,
conn
)
rpc.read(Request).then(request => {
// ...
})
API
Constructor:
opts.timeout
:Number
Default timeout for readingopts.lpFixed
:Boolean
Whether to use fixed length-prefixes instead of varInt onesopts.lpMaxLength
:Number
Default maximum message length in bytes for length-prefixed reads
.read(Proto[, max, timeout, fixed])
Read a Protocol Buffers message
Proto
: Protocol Buffers Protocol as returned byprotons
max
:Number
Maximum message length in bytestimeout
:Number
Timeout for readingfixed
:Boolean
Flag whether to use fixed length-prefixes instead of varInt ones
.write(Proto, data[, fixed])
Write a Protocol Buffers message
Proto
: Protocol Buffers Protocol as returned byprotons
data
:Object
Message payloadfixed
:Boolean
Flag whether to use fixed length-prefixes instead of varInt ones
.readLP([max, timeout, fixed])
Read a length-prefixed message
max
:Number
Maximum message length in bytestimeout
:Number
Timeout for readingfixed
:Boolean
Flag whether to use fixed length-prefixes instead of varInt ones
.writeLP(data[, fixed])
Write a length-prefixed message
data
:Buffer
Message payloadfixed
:Boolean
Flag whether to use fixed length-prefixes instead of varInt ones
.readRaw(bytes[, timeout])
Read bytes
bytes
:Number
Amount of bytes to readtimeout
:Number
Timeout for reading
.writeRaw(data)
Write bytes
data
:Buffer
Message payload