npm

Need private packages and team management tools?Check out npm Orgs. »

verdon

0.4.0 • 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

35

version

0.4.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability