package
Primacron is a high level abstraction build on top of Primus
npm install primacronGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Primacron is an ancient scientist who's responsible for building Unicron, the evil twin of Primus.
Primacron is a high level and highly opinionated interface for Primus which
provides multi-server logic through redis and plain HTTP. It introduces the
concept of forced validation for every single message it receives. This gives
you the guarantee that you can "safely" processes these messages once they are
emitted.
This high level interface is composed out of various Primus plugins that are maintained by the Primus project:
The module depends on redis which is used to store a socket address -> server IP dictionary shared among the servers. Please use http://redis.io to get detailed installation instructions.
The module is distributed through npm and can be installed using.
npm install --save primacronThe module exports a constructor function which takes two optional arguments.
Returns a new Primacron instance.
Arguments
server - Optional - An http/s server instance, automatically created if not
provided.options - Optional - An object with the configuration options. You can use
any option supported by Primus and the above mentioned plugins.Example
const Primacron = require('primacron');
const primacron = new Primacron({ port: 8080 });
primacron.validate('data', (message, next) => {
if (typeof message !== 'number') return next(new Error('Validation failed'));
next();
});
primacron.on('data', (spark, message) => console.log(message));
primacrom.on('invalid', (err) => console.error(err.stack));
jcrugzz
jcrugzz@gmail.com
Estimated unpacked size across 63 packages.
5.9 MB+
Includes dependencies.
2.0.x
3.0.1
0.0.x
0.0.5