Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document proper usage and API #4

Closed
nfantone opened this issue Jan 13, 2016 · 1 comment
Closed

Document proper usage and API #4

nfantone opened this issue Jan 13, 2016 · 1 comment
Labels

Comments

@nfantone
Copy link
Collaborator

Snippets found on README.md show examples of usage for a particular setup and doesn't showcase configuration options. Also, they don't work out of the box.

Another problem with the examples is that they somewhat contradict the following from the Getting Started guide on senecajs.org:

You export the plugin definition function and then call seneca.use with the name of the file. You can either require it in or if you like to be terse, let Seneca make the require call.

This doesn't hold true for this plugin as it expects the exported function of the module to be bound to the seneca instance:

module.exports = function(opts) {
    var seneca = this;
    var plugin = 'amqp-transport';
    var so = seneca.options();
    // ...

So, actually, you cannot require the module manually and must let seneca do that.

Anyway, this:

require('seneca')()
    .use(require('..'))
    .add({generate: 'id'}, function(message, done) {
        done(null, {pid: process.pid, id: '' + Math.random()});
    })
    .listen({type: 'amqp'});

Should really be something like:

require('seneca')()
      .use('seneca-amqp-transport', {
    amqp: {
      url: 'amqp://<username>:<password>@<hostname>:<port>'
    })
    .add({generate: 'id'}, function(message, done) {
        done(null, {pid: process.pid, id: '' + Math.random()});
    })
    .listen({type: 'amqp'});
@nfantone
Copy link
Collaborator Author

Documentation updated on #5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants