@nesn/commons-sqs-tools
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

SQS Tools Module Readme

This is a helper module for SQS handler, It provides configurable retry and error handling features for the handler, let devs focus on the logic of processing message.

Table of Contents

Introduction

Enable a message handler to do the following automatically

  • process batched messages in parallel
  • set retry interval
  • delete message on success
  • throw error on fail
  • return messageIds of failed messages to trigger a partial retry

Installation

To include the @nesn/commons-sqs-tools module in your project, you can install it using npm:

npm install @nesn/commons-sqs-tools

Usage

Importing

import { batchedMessageHandler } from '@nesn/commons-sqs-tools';

Wrap the handler

import { batchedMessageHandler } from '@nesn/commons-sqs-tools';

const mainHandler = (sqsEvent) => {
    // main logic done in here
};

export const handler = batchedMessageHandler({
    handler: mainHandler,
    retryStages: [
        { attempts: 3, interval: 30 }, // unit: second
        { attempts: 2, interval: 60 },
        { attempts: 1, interval: 120 }
    ],
    clientConfig: {
        credentials: {}, // overwrite credential if needed
        endpoint: '' // useful when local debug, local sqs endpoint can be set in here
    }
});

Customization

The @nesn/commons-sqs-tools module provides a default retry and error handling features for your handler. You can extend or modify it to suit your project's needs.

Contributing

Contributions to the @nesn/commons-sqs-tools module are welcome. If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.

License

The @nesn/commons-sqs-tools module is released under the MIT License. You can find the full license text in the module's package.json file.


Please note that this readme is provided as an example and might need adjustments based on your specific project and documentation guidelines.

Readme

Keywords

none

Package Sidebar

Install

npm i @nesn/commons-sqs-tools

Weekly Downloads

3

Version

1.4.0

License

MIT

Unpacked Size

24.4 kB

Total Files

31

Last publish

Collaborators

  • nesn-admin