| 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 { JobQueue } from "./JobQueue.ts"; |
| 5 | |
| 6 | /** The queue is injected by the binding; the request carries nothing else. */ |
| 7 | export interface GetJobQueueSnapshotRequest extends Omit< |
| 8 | batch.GetJobQueueSnapshotRequest, |
| 9 | "jobQueue" |
| 10 | > {} |
| 11 | |
| 12 | /** |
| 13 | * Snapshot the head of the bound AWS Batch job queue (the next ~100 `RUNNABLE` |
| 14 | * jobs the scheduler will run, in dispatch order) — queue introspection for |
| 15 | * dashboards and backpressure decisions from runtime code. |
| 16 | * |
| 17 | * ### Inspecting the Queue |
| 18 | * **Example:** Read the front of the queue |
| 19 | * ```typescript |
| 20 | * const getJobQueueSnapshot = yield* Batch.GetJobQueueSnapshot(queue); |
| 21 | * const { frontOfQueue } = yield* getJobQueueSnapshot(); |
| 22 | * const next = frontOfQueue?.jobs?.[0]?.jobArn; |
| 23 | * ``` |
| 24 | * |
| 25 | * @binding |
| 26 | */ |
| 27 | export interface GetJobQueueSnapshot extends Binding.Service< |
| 28 | GetJobQueueSnapshot, |
| 29 | "AWS.Batch.GetJobQueueSnapshot", |
| 30 | ( |
| 31 | queue: JobQueue, |
| 32 | ) => Effect.Effect< |
| 33 | ( |
| 34 | request?: GetJobQueueSnapshotRequest, |
| 35 | ) => Effect.Effect< |
| 36 | batch.GetJobQueueSnapshotResponse, |
| 37 | batch.GetJobQueueSnapshotError |
| 38 | > |
| 39 | > |
| 40 | > {} |
| 41 | export const GetJobQueueSnapshot = Binding.Service<GetJobQueueSnapshot>( |
| 42 | "AWS.Batch.GetJobQueueSnapshot", |
| 43 | ); |