Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
laconia-batch
Advanced tools
🛡️ Laconia Batch — Reads large number of records without time limit.
Reads large number of records without Lambda time limit.
AWS Lambda maximum execution duration per request is 300 seconds, hence it is
impossible to utilise a Lambda to execute a long running task. laconia-batch
handles your batch processing needs by providing a beautifully designed API
which abstracts the time limitaton problem.
Check out FAQ
Install laconia-batch using yarn:
yarn add laconia-batch
Or via npm:
npm install --save laconia-batch
These are the currently supported input sources:
Example of batch processing by scanning a dynamodb table:
const laconiaBatch = require("laconia-batch");
module.exports.handler = laconiaBatch(
_ =>
laconiaBatch.dynamoDb({
operation: "SCAN",
dynamoDbParams: { TableName: "Music" }
}),
{ itemsPerSecond: 2 }
).on("item", ({ event }, item) => processItem(event, context));
Rate limiting is supported out of the box by setting the batchOptions.itemsPerSecond
option.
laconia-batch
works around the Lambda's time limitation by using recursion.
It will automatically recurse when Lambda timeout is about to happen, then resumes
from where it left off in the new invocation.
Imagine if you are about to process the array [1, 2, 3, 4, 5] and each requests can only handle two items, the following will happen:
laconiaBatch(readerFn, batchOptions)
readerFn(laconiaContext)
Function
is called when your Lambda is invokeddynamoDb()
, s3()
laconiaContext
object, which can be destructured to {event, context}
batchOptions
itemsPerSecond
timeNeededToRecurseInMillis
Example:
// Use all default batch options (No rate limiting)
laconiaBatch(_ => dynamoDb());
// Customise batch options
laconiaBatch(_ => dynamoDb(), {
itemsPerSecond: 2,
timeNeededToRecurseInMillis: 10000
});
There are events that you can listen to when laconia-batch
is working.
laconiaContext, item
item
is an object found during the readlaconiaContext
can be destructured to {event, context}
laconiaContext
laconiaContext
can be destructured to {event, context}
laconiaContext, cursor
cursor
contains the information of how the last item is being readlaconiaContext
can be destructured to {event, context}
laconiaContext
laconiaContext
can be destructured to {event, context}
Example:
laconiaBatch({ ... })
.on('start', (laconiaContext) => ... )
.on('item', (laconiaContext, item) => ... )
.on('stop', (laconiaContext, cursor) => ... )
.on('end', (laconiaContext) => ... )
dynamoDb(readerOptions)
Creates a reader for Dynamo DB table.
operation
'SCAN'
and 'QUERY'
dynamoDbParams
ExclusiveStartKey
param can't be used as it will be overridden in the processing time!documentClient = new AWS.DynamoDB.DocumentClient()
Example:
// Scans the entire Music table
dynamoDb({
operation: "SCAN",
dynamoDbParams: { TableName: "Music" }
});
// Queries Music table with a more complicated DynamoDB parameters
dynamoDb({
operation: "QUERY",
dynamoDbParams: {
TableName: "Music",
Limit: 1,
ExpressionAttributeValues: {
":a": "Bar"
},
FilterExpression: "Artist = :a"
}
});
s3(readerOptions)
Creates a reader for an array stored in s3.
path
'.'
if the object stored in s3 is the arraylodash.get
is used to retrieve the arrays3Params
s3.getObject
is called to retrieve the array stored in s3s3 = new AWS.S3()
Example:
// Reads an array from array.json in MyBucket
s3({
path: ".",
s3Params: {
Bucket: "MyBucket",
Key: "array.json"
}
});
// Reads the array retrieved at database.music[0]["category"].list from object.json in MyBucket
s3({
path: 'database.music[0]["category"].list',
s3Params: {
Bucket: "MyBucket",
Key: "object.json"
}
});
[0.4.0]
laconia-invoke
laconia-core
laconia-invoke
packagelaconia-core
laconia
function is now a default export instead of a named exportlaconia-test
laconiaTest
function is now a default export instead of a named exportlaconia-batch
laconiaBatch
function is now a default export instead of a named exportFAQs
Reads large number of records without Lambda time limit.
We found that laconia-batch 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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.