Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

seneca-sqs-transport

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seneca-sqs-transport

A Seneca.js transport plugin to transfer messages over SQS.

  • 0.1.1
  • unpublished
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

seneca-sqs-transport

A Seneca.js transport plugin to transfer messages over SQS.

ES6 transpiling

TODO Remove this documentation piece before publishing to npm repository

To be able to use the module in our Meteor application, a transpiling step via babel was added. Please note that both src and lib directories are added to git, as module is installed via direct link, not via npm, so compiled code needs to be there.

TODO Set up .gitignore and .npmignore before publishing to npm repository

Listener

Listener polls preconfigured SQS queue for messages, processes requests and sends responses back to clients. By default each request message contains a property with queue URL to send the response to.

If that property is empty, the client is considered to be not interested in the response data and the message is just silently executed without sending any responses.

A simple listener may look like this:

const seneca = require('seneca');

seneca({ timeout: 30000 })
  .use('seneca-sqs-transport')
  .add('role: test, cmd: echo', (args, done) => {
    done(null, { message: args.message });
  })
  .listen({
    type: 'sqs',
    accessKeyId: process.env.SQS_KEY,
    secretAccessKey: process.env.SQS_SECRET_KEY,
    queueUrl: process.env.SQS_QUEUE_URL,
  });

Client

Client sends request messages to the preconfigured SQS queue. Also it creates new personal queue on startup to receive response messages over it. That queue URL is sent over as a request message property, so listener knows whom to reply to.

There is an option to skip creating that personal response queue. In that case client does not wait till listener executes an action. Client just waits for SQS to accept the request message. Then action callback is immediately executed using AWS.SQS.sendMessage result as an argument.

A simple client may look like this:

const seneca = require('seneca');
const client = seneca({ timeout: 30000 })
  .use('seneca-sqs-transport')
  .client({
    type: 'sqs',
    accessKeyId: process.env.SQS_KEY,
    secretAccessKey: process.env.SQS_SECRET_KEY,
    queueUrl: process.env.SQS_QUEUE_URL,
    responseQueuePrefix: 'test_echo_',
  });

setInterval(() => {
  client.act('role: test, cmd: echo, message: hello', console.log);
}, 2000);

Options

These are the default options used by the plugin:

const defaults = {
  sqs: {
    type: 'sqs',
    accessKeyId: '',
    secretAccessKey: '',
    region: 'us-east-1',
    queueUrl: '',
    responseQueuePrefix: '',
    noResponse: false,
    maxNumberOfMessages: 1,
  },
};
OptionTypeDescription
accessKeyIdStringAWS access key
secretAccessKeyStringAWS secret key
regionStringAWS region
queueUrlStringSQS queue URL to send (client) and receive (listener) messages to/from.
responseQueuePrefixStringPrefix to append to the name of client's personal response queue name.
noResponseBooleanDefines if client should wait for server response to come. If set to true client callback is executed immediately after sending a message.
maxNumberOfMessagesIntegerThe number of simultaneously processed messages.

Examples

There are simple client and listener examples in examples directory. They rely on the following environment variables to be defined:

  • SQS_KEY
  • SQS_SECRET_KEY
  • SQS_QUEUE_URL

TODO

  • Tests
  • Remove AWS information from seneca logs
  • Handle occasional client exception when it is terminated while processing the response

Keywords

FAQs

Package last updated on 11 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc