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

Seneca is using internal communications before the action declared in pins. #546

Open
SzybkiSasza opened this issue Sep 16, 2016 · 1 comment
Assignees

Comments

@SzybkiSasza
Copy link

SzybkiSasza commented Sep 16, 2016

When we create Seneca instance with pins that expose some functionalities to the outside world, Seneca tends to use internal communications before trying the actions declared in pins. As we have some special retrying policies set in transport (based on SQS queues), we would like Seneca to send message to the outside world, if it has particular listening pin exposed. Is it possible?

The code is as follows:

const seneca = require('seneca')({});

seneca
  .use('./plugin')
  .use('./another-plugin')
  .client({
    type: 'sqs',
    /** Our transport settings here **/
    pin: 'role: plugin, cmd: *'
  })
 .client({
    type: 'sqs',
    /** Our transport settings here **/
    pin: 'role: another-plugin, cmd: *'
  });

seneca.ready(error => {
  if (error) return;

  if (process.env.LISTEN_HOST) {
    seneca.listen({
      host: process.env.LISTEN_HOST,
      port: process.env.LISTEN_PORT
    });
  }

  if (process.env.QUEUE_URL) {
    seneca.listen({
      type: 'sqs',
      /** Our transport settings here **/
    });
  }
});

And exposed roles are as follows:

  seneca.add({
      role: 'another-plugin',
      cmd: 'some-command',
      joi$: actionSchemas.someCommandSchema
    }, someCommand);

So, based on examples above, scenario is as follows:

  1. Some external microservice calls action on plugin
  2. Plugin calls Seneca action on another-plugin
  3. another-plugin starts executing action immediately, as it's called internally
  4. If another-plugin fails, it returns error immediately to plugin

What we would want to achieve, is to call Seneca action over our transport between 2 and 3 step if pins that are needed for fulfilling the action are exposed by any client command. Is it possible?

We use Seneca 2.1.

@SzybkiSasza SzybkiSasza changed the title Seneca is using internal communications before the one declared in pins. Seneca is using internal communications before the action declared in pins. Sep 16, 2016
@rjrodger
Copy link
Collaborator

@SzybkiSasza this should work out of the box, so long as the pin expressions are equal.
I am understanding correctly? Thanks for the code example :)

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

No branches or pull requests

2 participants