| 1 | import type * as batch from "@distilled.cloud/aws/batch"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { JobDefinition } from "./JobDefinition.ts"; |
| 5 | import type { JobQueue } from "./JobQueue.ts"; |
| 6 | |
| 7 | /** |
| 8 | * The queue and job definition are injected by the binding; everything else |
| 9 | * (name, parameters, container overrides, ...) is the raw distilled request. |
| 10 | */ |
| 11 | export interface SubmitJobRequest extends Omit< |
| 12 | batch.SubmitJobRequest, |
| 13 | "jobQueue" | "jobDefinition" |
| 14 | > {} |
| 15 | |
| 16 | /** |
| 17 | * Submit a job to an AWS Batch job queue against a bound job definition — |
| 18 | * fire-and-forget heavy work from a Lambda or Task. |
| 19 | * |
| 20 | * ### Submitting Jobs |
| 21 | * **Example:** Submit from a Lambda |
| 22 | * ```typescript |
| 23 | * const submitJob = yield* Batch.SubmitJob(queue, jobDef); |
| 24 | * const { jobId } = yield* submitJob({ |
| 25 | * jobName: "nightly-export", |
| 26 | * containerOverrides: { command: ["echo", "hello"] }, |
| 27 | * }); |
| 28 | * ``` |
| 29 | * |
| 30 | * @binding |
| 31 | */ |
| 32 | export interface SubmitJob extends Binding.Service< |
| 33 | SubmitJob, |
| 34 | "AWS.Batch.SubmitJob", |
| 35 | ( |
| 36 | queue: JobQueue, |
| 37 | jobDefinition: JobDefinition, |
| 38 | ) => Effect.Effect< |
| 39 | ( |
| 40 | request: SubmitJobRequest, |
| 41 | ) => Effect.Effect<batch.SubmitJobResponse, batch.SubmitJobError> |
| 42 | > |
| 43 | > {} |
| 44 | export const SubmitJob = Binding.Service<SubmitJob>("AWS.Batch.SubmitJob"); |