| 1 | import type * as emrc from "@distilled.cloud/aws/emr-containers"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { VirtualCluster } from "./VirtualCluster.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Runtime binding for `emr-containers:DescribeJobRun`. |
| 8 | * |
| 9 | * Reads a job run on the bound {@link VirtualCluster} — its state |
| 10 | * (`PENDING` → `RUNNING` → `COMPLETED`/`FAILED`/`CANCELLED`), failure |
| 11 | * reason, and the resolved driver/configuration. The virtual cluster ID is |
| 12 | * injected from the binding; pass the job run `id` returned by |
| 13 | * `StartJobRun`. Provide the implementation with |
| 14 | * `Effect.provide(AWS.EMRContainers.DescribeJobRunHttp)`. |
| 15 | * ### Running Jobs |
| 16 | * **Example:** Poll A Job Run Until It Finishes |
| 17 | * ```typescript |
| 18 | * // init |
| 19 | * const describeJobRun = yield* AWS.EMRContainers.DescribeJobRun(virtualCluster); |
| 20 | * |
| 21 | * // runtime |
| 22 | * const { jobRun } = yield* describeJobRun({ id: jobRunId }).pipe( |
| 23 | * Effect.repeat({ |
| 24 | * schedule: Schedule.spaced("15 seconds"), |
| 25 | * until: (r) => |
| 26 | * r.jobRun?.state === "COMPLETED" || r.jobRun?.state === "FAILED", |
| 27 | * times: 40, |
| 28 | * }), |
| 29 | * ); |
| 30 | * ``` |
| 31 | * |
| 32 | * @binding |
| 33 | */ |
| 34 | export interface DescribeJobRun extends Binding.Service< |
| 35 | DescribeJobRun, |
| 36 | "AWS.EMRContainers.DescribeJobRun", |
| 37 | ( |
| 38 | virtualCluster: VirtualCluster, |
| 39 | ) => Effect.Effect< |
| 40 | ( |
| 41 | request: Omit<emrc.DescribeJobRunRequest, "virtualClusterId">, |
| 42 | ) => Effect.Effect<emrc.DescribeJobRunResponse, emrc.DescribeJobRunError> |
| 43 | > |
| 44 | > {} |
| 45 | export const DescribeJobRun = Binding.Service<DescribeJobRun>( |
| 46 | "AWS.EMRContainers.DescribeJobRun", |
| 47 | ); |