npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

power-sqs

v1.8.29

Published

powerful functions to deal with AWS SQS

Downloads

215

Readme

Travis badge Known Vulnerabilities

NPM

power-sqs

Power-SQS is a set of powerful functions to deal with AWS SQS. It includes stream to read messages, move messages from one SQS to another or to a persistent data store.

If you just want to use sink operations, there is an option availble to use them via cli. Please see power-sqs-cli

How to install

npm install power-sqs
yarn add power-sqs

How To Use

Power SQS provides following functions to deal with AWS SQS

Reader

getSQSReader

Returns a readable stream of messages with long polling of 10 seconds. The object mode is enabled in the stream and pushes single message across the pipe.

const {getSQSReader} = require("power-sqs");

const config = {"url": "your sqs url"};
const sqsReader = getSQSReader(config);

// returns a Node.js readable stream.

sqsReader.pipe("stream of your choice.")

getSQSPowerReader

Returns a highland stream. The stream can then be used to apply transformers like filter, map, find and etc to generate a stream of data before piping it to another stream.

Please see highland transformers for more information.

const {getSQSPowerReader} = require("power-sqs");

const config = {"url": "your sqs url"};
const sqsReader = getSQSPowerReader(config);

// returns a Node.js readable stream.

sqsReader.filter(() => {
  // filter logic
}).pipe("stream of your choice");

getSQSBulkReader

Returns a readable stream of messages with long polling of 10 seconds. The object mode is enabled in the stream and returns the complete data object returned from the AWS.

The messgages in the pushed chunk can be accessed via the the Messages. It only pushes the data if it has any number of Messages attached to it otherwise it will keep on polling the SQS.

const {getSQSBulkReader} = require("power-sqs");

const config = {"url": "your sqs url"};
const sqsReader = getSQSBulkReader(config);

// returns a Node.js readable stream.

sqsReader.pipe("stream of your choice.")

DeleteMessages

Allows you to delete the messages in batch

const {deleteMessages} = require("power-sqs");

const queueUrl = "your sqs url";
const messages = [{}] // array of messages you want to delete

return deleteMessages(queueUrl, messages)
.then(res => console.log(res));

SendMessages

Allows you to send the messages in batch

const {sendMessages} = require("power-sqs");

const queueUrl = "your sqs url";
const messages = [{"foo": "bar"}] // data you want to send as messages

return sendMessages(queueUrl, messages)
.then(res => console.log(res));

SendFifoMessages

Allows you to send the messages in batch

const {sendFifoMessages} = require("power-sqs");

const queueUrl = "your sqs url";
const group = "groupid";
const messages = [{"foo": "bar"}] // data you want to send as messages

return sendFifoMessages(queueUrl, group, messages)
.then(res => console.log(res));

receiveMessages

Allows you to receive the messages from a sqs. If you are looking for something to poll continuously, have a look at other reader functions which provide streaming and filtering options too.

const {sendMessages} = require("power-sqs");

const queueUrl = "your sqs url";

return receiveMessages(queueUrl)
.then(res => console.log(res));

Sink

initSinkToSQS

Allows you to move messages from one SQS to another in same AWS Account.

const {initSinkToSQS} = require("power-sqs");

const source = {"url": "your sqs url"};
const destination = {"url": "your sqs url"};
const config = {source, destination};

initSinkToSQS(config);

Examples

some of the examples related to specifically single operations like sendMessages, deleteMessages etc are provided in examples directory.

Support or Contact

Having trouble with power-sqs or have any questions? Please raise an issue.