Neurophysiologically Pseudoscientific Manatee

npm

npm’s 2019 JavaScript ecosystem survey analysis is now available! Get your copy here »

verdon

0.3.4 • Public • Published

Verdon NPM version Build status Coverage status

Avro services utilities.

Proxies

Sample Avro remote logging service running behind a WebSocket server:

const avro = require('avsc');
const http = require('http');
const verdon = require('verdon');
 
const protocol = avro.readProtocol(`
  protocol RemoteLogService {
    enum Level { DEBUG, INFO, WARNING }
    void log(Level level, string message);
  }
`);
 
const logServer = avro.Service.forProtocol(protocol).createServer()
  .onLog(function (level, msg) { console.log(`${level}${msg}`); });
 
const proxy = verdon.createProxy().bindServer(logServer);
 
http.createServer()
  .on('upgrade', proxy.webSocketHandler())
  .listen(8080);

And a corresponding client:

const avro = require('avsc');
const ws = require('websocket-stream');
 
const protocol = avro.readProtocol(`
  protocol RemoteLogService {
    void log(enum { INFO, WARNING } level, string message);
  }
`);
 
const logClient = avro.Service.forProtocol(protocol)
  .createClient({buffering: true, transport: ws('ws://localhost:8080')});
 
logClient.log('INFO', 'We are now live!');
 
setTimeout(function () {
  logClient.log('WARNING', 'And soon we will not.');
  logClient.destroyChannels();
}, 1000);

Keywords

install

npm i verdon

Downloadsweekly downloads

18

version

0.3.4

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability