Function recordProcessorAdapter

recordProcessorAdapter - adapts a single record processor effect to a batch processor effect

you can control the concurrency of the batch processing by setting the concurrency outside of this function, with the default being unbounded.

import { Console, Effect, Either } from 'effect';
import { SQSRecord, toLambdaHandler, recordProcessorAdapter } from '@effect-lambda/Sqs';
// Define an effect that processes a single SQS record
const processRecord = SQSRecord.pipe(
Effect.tap((record) => Console.log(record.body))
);

// Adapt the single record processor effect to handle a batch of records and use it with an SQSEventHandler
export const handler = processRecord.pipe(
recordProcessorAdapter<never>, // type parameter is required due to TypeScript limitations
Effect.withConcurrency(1), // optional if want sequential processing
toLambdaHandler,
);
  • Type Parameters

    Parameters

    • effect: Effect<void, any, R>

      Effect.Effect<void, E, SQSRecord> - an effect handling a single SQS record

    Returns Effect<BatchResponse, never, SQSEvent | Exclude<R, SQSRecord>>

    A handler effect compatible with SQSEventHandler