0.3.2 • Published 9 months ago

@driimus/lambda-batch-processor v0.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@driimus/lambda-batch-processor

npm

Concurrently process batch records with partial failure support.

Installation

!WARNING This is an ES only package. Before installing, make sure that your project's configuration supports ECMAScript modules.

pnpm add @driimus/lambda-batch-processor

Type hints

For types to work as expected, @types/aws-lambda must be installed:

pnpm add --save-dev @types/aws-lambda

Usage

!WARNING(https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting) must be enabled to allow retrying failed messages.

import { SQSBatchProcessor } from '@driimus/lambda-batch-processor';

const processor = new SQSBatchProcessor(async (record) => {
  /** do stuff */
});

export const handler = processor.process;

Supported event sources:

  • DynamoDB Streams

    import { DynamoDBBatchProcessor } from '@driimus/lambda-batch-processor';
  • Kinesis Data Streams

    import { KinesisBatchProcessor } from '@driimus/lambda-batch-processor';
  • SQS

    import { SQSBatchProcessor } from '@driimus/lambda-batch-processor';

Non-retryable errors

Exceptions that occur during batch processing can be treated as permanent failures.

This feature is inspired from the AWS Lambda Powertools for Java, with one key difference: By default, messages that trigger permanent failures will not be reported. In the case of SQS messages, the result will be their deletion from the queue. To send SQS messages to a dead-letter queue, you can use @driimus/sqs-permanent-failure-dlq.

Logging

Logging can be enabled by providing a logger compatible with the Logger interface, which is modelled after pino's function signatures.

!NOTE The provided logger should support serialising AggregateError objects.

Alternatives

Don't need special handling for non-retryable errors? Make sure to check out the implementation in AWS Lambda Powertools for Typescript, which has added ESM support in v2.

0.3.0

12 months ago

0.3.2

9 months ago

0.3.1

10 months ago

0.2.0

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.3

3 years ago

0.1.0

3 years ago