
Security News
PEP 810 Proposes Explicit Lazy Imports for Python 3.15
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
@boostercloud/rocket-batch-file-process-aws-infrastructure
Advanced tools
Booster rocket to batch process files.
This package is a configurable Booster rocket for parallel batch file processing. First, it creates a source Object Storage (S3) and a Staging Object Storage(S3).
Every time a new File is uploaded to the Source S3 Bucket, a new Lambda function will be triggered that will:
chunkSize
is defined by the user as input parameter of the rocket (See example below).fileUri
and fileSize
) in the Events Store for each chunk created.Then, for every chunk file dropped in the Staging rocket a new Lambda function will be triggered that will:
This event is registered in the Booster application's store as a regular event. Then, you can create event handlers to perform any kind of processing.
You drop your file, and you implement your logic based on an event representing a line of the file.
Disclaimer: Currently the rocket supports CSV and jsonl files.
Install this package as a dependency in your Booster project.
npm install --save @boostercloud/rocket-batch-file-process-aws-infrastructure
In your Booster config file, pass a RocketDescriptor
array to the AWS' Provider
initializer configuring the batch file rocket:
import { Booster } from '@boostercloud/framework-core'
import { BoosterConfig } from '@boostercloud/framework-types'
Booster.configure('development', (config: BoosterConfig): void => {
config.appName = 'test-app'
config.providerPackage = '@boostercloud/framework-provider-aws'
config.rockets = [
{
packageName: '@boostercloud/rocket-batch-file-process-aws-infrastructure',
parameters: {
bucketName: 'test-bucket',
files: [
{
folderName: 'addresses',
numberOfRecordsInParallel: '100',
},
],
},
},
]
})
Based on this example let's also define the AddressAdded
event and the AddressEntity
entity in your Booster project
import { Event } from '@boostercloud/framework-core'
import { UUID } from '@boostercloud/framework-types'
@Event
export class AddressAdded {
public constructor(
readonly id: UUID,
readonly firstName: string,
readonly lastName: string,
readonly address: string,
readonly city: string,
readonly state: string,
readonly postalCode: string
) {}
public entityID(): UUID {
return this.id
}
}
import { Entity, Reduces } from '@boostercloud/framework-core'
import { AddressAdded } from '../events/address-added'
import { UUID } from '@boostercloud/framework-types'
@Entity
export class AddressEntity {
public constructor(
public id: UUID,
readonly firstName: string,
readonly lastName: string,
readonly address: string,
readonly city: string,
readonly state: string,
readonly postalCode: string
) {}
@Reduces(AddressAdded)
public static reduceAddressAdded(event: AddressAdded, currentAddressEntity?: AddressEntity): AddressEntity {
return new AddressEntity(
event.id,
event.firstName,
event.lastName,
event.address,
event.city,
event.state,
event.postalCode
)
}
}
The attributes of the AddressAdded
and AddressEntity
classes are defined by the structure of the input file.
This is an example of CSV file that will work with what we defined above:
entityId:id,eventTypeName:AddressAdded,entityTypeName:AddressEntity
id,firstName,lastName,address,city,state,postalCode
1a,John,Doe,120 jefferson st.,Riverside, NJ, 08075
2b,Jack,McGinnis,220 hobo Av.,Phila, PA,09119
3c,"John ""Da Man""",Repici,120 Jefferson St.,Riverside, NJ,08075
4d,Stephen,Tyler,"7452 Terrace ""At the Plaza"" road",SomeTown,SD, 91234
5e,,Blankman,,SomeTown, SD, 00298
6f,"Joan ""the bone"" Anne",Jet,"9th at Terrace plc",Desert City,CO,00123
7g,Juan,Perez,120 jota st.,NY,NY,00678
The first row instructs the rocket which fields should it generate for which events/entities.
The second row of the CSV file defines the headers of the schema and is a 1 to 1 match with the AddressAdded
and AddressEntity
attributes definition.
If we were to use jsonl
files instead of csv
, this would be an example
{"entityId":"id","eventTypeName":"AddressAdded","entityTypeName":"AddressEntity"}
{"id": "1a", "firstName": "John", "lastName": "Doe", "address": "120 jefferson st.", "city": "Riverside", "state": "NJ", "postalCode": "08075"}
{"id": "2b", "firstName": "Jack", "lastName": "McGinnis", "address": "220 hobo Av.", "city": "Phila", "state": "PA", "postalCode": "09119"}
The first line of the jsonl file is also used to specify some metadata.
As a result the event handler will look as following
import { EventHandler } from '@boostercloud/framework-core'
import { Register } from '@boostercloud/framework-types'
import { AddressAdded } from '../events/address-added'
@EventHandler(AddressAdded)
export class AddressEventHandler {
public static async handle(event: AddressAdded, register: Register): Promise<void> {
...
}
}
FAQs
Booster rocket to batch process files.
We found that @boostercloud/rocket-batch-file-process-aws-infrastructure demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 14 open source maintainers 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
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.