Axon
Axon is a message-oriented socket library for node.js heavily inspired by zeromq. For a light-weight UDP 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
closewhen server or connection is closederror(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 attemptwhen a reconnection attempt is made
connectwhen connected to the peer, or a peer connection is accepteddisconnectwhen an accepted peer disconnectsbindwhen the server is bounddrop(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 types
Backed by node-amp-message you may pass strings, objects, and buffers as arguments.
push.send('image', { w: 100, h: 200 }, imageBuffer);
pull.on('message', function(type, size, img){});
Push / Pull
PushSockets distribute messages round-robin:
var axon = require('axon');
var sock = axon.socket('push');
sock.bind(3000);
console.log('push server started');
setInterval(function(){
sock.send('hello');
}
}, 150);
});
}, 500);
});
});
});
});
});
});
}, 500);
});
});
});