。。。。。。。

106 阅读1分钟

AxonAxon is a message-oriented socket library for node.js heavily inspired by zeromq. For a light-weightUDP alternative you may be interested in punt.## Installation$ npm install axon## Features- message oriented- automated reconnection- light-weight wire protocol- mixed-type arguments (strings, objects, buffers, etc)- unix domain socket support- fast (~800 mb/s ~500,000 messages/s)## Events- close when server or connection is closed- error (err) when an un-handled socket error occurs- ignored error (err) when an axon-handled socket error occurs, but is ignored- socket error (err) emitted regardless of handling, for logging purposes- reconnect attempt when a reconnection attempt is made- connect when connected to the peer, or a peer connection is accepted- disconnect when an accepted peer disconnects- bind when the server is bound- drop (msg) when a message is dropped due to the HWM- flush (msgs) queued when messages are flushed on connection## Patterns- push / pull- pub / sub- req / rep- pub-emitter / sub-emitter## Mixed argument typesBacked by node-amp-messageyou may pass strings, objects, and buffers as arguments.jspush.send('image', { w: 100, h: 200 }, imageBuffer);pull.on('message', function(type, size, img){});## Push / PullPushSockets distribute messages round-robin:```jsvar axon = require('axon');var sock = axon.socket('push');sock.bind(3000);console.log('push server

started');setInterval(function(){sock.send('hello');

}, 150);});

}, 500);});});});});});});}, 500);});});});