seneca-amqp
A small module that builds a pre-configured seneca instance using AMQP as its transport
Last updated 4 years ago by nfantone .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install seneca-amqp 
SYNC missed versions from official npm registry.

Seneca

js-semistandard-style

A Seneca.js AMQP-ready thin wrapper.

seneca-amqp

Small module that helps create a pre-configured seneca (http://senecajs.org/) instance that uses AMQP as its transport layer and eases declaration of clients and listeners.

npm install --save seneca-amqp

Usage

You use this module as a direct replacement for seneca, which is declared in peerDependencies (so you can install the version you need). The returned instance uses seneca-amqp-transport and has a .start function that'll declare listeners and clients for you (no need to call .listen or .client).

var config = {
   seneca: {
     // Any global seneca option
    timeout: 3000
   },
   amqp: {
    // Broker connection settings
    hostname: 'dev.rabbitmq.com',
    port: 5672,
    username: 'guest',
    password: 'guest'
   },
   pins: {
    // Pins used in .client and .listen methods
    client: 'role:entity,cmd:save',
    listen: ['level:info', 'cmd:rollback,proc:status']
  },
  autoStart: false
};

var seneca = require('seneca-amqp')(config);
seneca.start()
  .then(() => console.log('Seneca is ready'))
  .catch(console.error);

Additional features

The seneca instance created by this module,

  • Uses seneca-amqp-transport as its transport layer. There's no need to declare it as en explicit dependency: this module will do that for you.
  • Simplifies configuration of the AMQP broker and declaration of client/listeners to a minimum.
  • Defines a new seneca.actAsync method that behaves like a promisified seneca.act.

In previous versions this was named seneca.pact. That is now deprecated. Please, use seneca.actAsync instead.

  • Adds a new seneca.start method that returns a promise that fulfills when all clients and listeners have been declared and fired up.
  • Disables 'mem-store' by default. It is assumed that stores are listeners in remote microservice wired up in an AMQP fashion.

If you need to enable it back, you can pass { seneca: { default_plugins: { 'mem-store': true } } to the configuration object.

License

MIT

Current Tags

  • 1.1.1                                ...           latest (4 years ago)

7 Versions

  • 1.1.1                                ...           4 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.3                                ...           5 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
  • 1.0.1-dev                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |