Skip to content

Commit 24c36ee

Browse files
author
remote-swe-app[bot]
committed
docs: make subdirectory pattern the standard for async jobs
1 parent cae3e93 commit 24c36ee

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

webapp/README.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,30 +188,24 @@ This project uses type-safe server actions with authentication:
188188

189189
### Asynchronous Jobs
190190

191-
Asynchronous jobs are Lambda functions that handle long-running or background tasks. The `job.Dockerfile` builds all TypeScript files in `src/jobs/` into separate Lambda handlers using `esbuild src/jobs/*.ts --bundle`.
191+
Asynchronous jobs are Lambda functions that handle long-running or background tasks. All async jobs are invoked through a single Lambda function (`async-job-runner.ts`) and can be triggered manually or as scheduled jobs.
192192

193193
**File structure:**
194194

195-
For simple jobs, place a single file directly under `src/jobs/`:
195+
Place each job's implementation in a subdirectory under `src/jobs/`:
196196

197197
```
198198
webapp/src/jobs/
199-
├── migration-runner.ts # Single-file Lambda handler
200-
└── async-job-runner.ts # Single-file Lambda handler
201-
```
202-
203-
For jobs with complex logic, use a subdirectory:
204-
205-
```
206-
webapp/src/jobs/
207-
├── async-job-runner.ts # Lambda handler entry point
208-
└── async-job/ # Business logic directory
199+
├── async-job-runner.ts # Lambda handler entry point (dispatches to jobs)
200+
└── async-job/ # Job implementations directory
209201
└── translate.ts # Job implementation
210202
```
211203

204+
The `async-job-runner.ts` handler dispatches to the appropriate job based on the event payload type.
205+
212206
**Deployment:**
213207

214-
All jobs share the same `job.Dockerfile`. The CDK stack overrides the entry point using the `cmd` parameter in `DockerImageCode.fromImageAsset()`:
208+
The `job.Dockerfile` builds all TypeScript files in `src/jobs/` using `esbuild src/jobs/*.ts --bundle`. The CDK stack overrides the entry point using the `cmd` parameter:
215209

216210
```typescript
217211
// Example from cdk/lib/constructs/async-job.ts

0 commit comments

Comments
 (0)