@rvkang/batch-nest
v0.1.0
Published
NestJS integration for nest-batch.
Downloads
98
Maintainers
Readme
@rvkang/batch-nest
NestJS module, decorator discovery, and runtime integration for nest-batch.
Install
pnpm add @rvkang/batch-nest
pnpm add @rvkang/batch-core @rvkang/batch-inmemory @nestjs/common @nestjs/core reflect-metadata@nestjs/common, @nestjs/core, and reflect-metadata are peer dependencies.
Configure a module
import "reflect-metadata";
import { defineStep } from "@rvkang/batch-core";
import { Module } from "@nestjs/common";
import { NestFactory } from "@nestjs/core";
import { InMemoryBatchStorage } from "@rvkang/batch-inmemory";
import { BatchJob, BatchStep, NestBatchModule } from "@rvkang/batch-nest";
@BatchJob("hello")
class HelloJob {
@BatchStep("log")
log() {
return defineStep({ name: "log", execute: async () => "done" });
}
}
@Module({
imports: [NestBatchModule.forRoot({ storage: new InMemoryBatchStorage() })],
providers: [HelloJob]
})
export class AppModule {}
const app = await NestFactory.createApplicationContext(AppModule, { logger: false });
await app.close();InMemoryBatchStorage is non-durable; use a SQL storage adapter when execution
history, checkpoints, restart, or multi-process coordination must survive a
process restart. Make writer side effects idempotent for at-least-once work.
