
Product
Go Support Is Now Generally Available
Socket's Go support is now generally available, bringing automatic scanning and deep code analysis to all users with Go projects.
seneca-sqs-transport
Advanced tools
A Seneca.js transport plugin to transfer messages over SQS.
A Seneca.js transport plugin to transfer messages over SQS.
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 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 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);
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,
},
};
Option | Type | Description |
---|---|---|
accessKeyId | String | AWS access key |
secretAccessKey | String | AWS secret key |
region | String | AWS region |
queueUrl | String | SQS queue URL to send (client) and receive (listener) messages to/from. |
responseQueuePrefix | String | Prefix to append to the name of client's personal response queue name. |
noResponse | Boolean | Defines if client should wait for server response to come. If set to true client callback is executed immediately after sending a message. |
maxNumberOfMessages | Integer | The number of simultaneously processed messages. |
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
FAQs
A Seneca.js transport plugin to transfer messages over SQS.
The npm package seneca-sqs-transport receives a total of 0 weekly downloads. As such, seneca-sqs-transport popularity was classified as not popular.
We found that seneca-sqs-transport demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket's Go support is now generally available, bringing automatic scanning and deep code analysis to all users with Go projects.
Security News
vlt adds real-time security selectors powered by Socket, enabling developers to query and analyze package risks directly in their dependency graph.
Security News
CISA extended MITRE’s CVE contract by 11 months, avoiding a shutdown but leaving long-term governance and coordination issues unresolved.