| 1 | import * as GCP from "@/GCP"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import { serveProbes } from "../../bindingHost.ts"; |
| 4 | import { CAPACITY_REGION } from "../../zones.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Cluster the bindings target: GetCluster is granted on it |
| 8 | * (roles/dataproc.viewer), SubmitJob on the project (roles/dataproc.editor). |
| 9 | */ |
| 10 | export const Jobs = GCP.Dataproc.Cluster("Jobs", { |
| 11 | region: CAPACITY_REGION, |
| 12 | // No zone: Dataproc Auto Zone Placement picks a zone in the region with |
| 13 | // capacity, so a single-zone stockout cannot fail the deploy. |
| 14 | }); |
| 15 | |
| 16 | /** |
| 17 | * Effect-native Cloud Run service exercising every Dataproc binding as its |
| 18 | * own runtime service account. Deployed from {@link ../Bindings.test.ts}. |
| 19 | */ |
| 20 | export default class DataprocBindingsHost extends GCP.Function<DataprocBindingsHost>()( |
| 21 | "DataprocBindingsHost", |
| 22 | { main: import.meta.url, invokerIamDisabled: true }, |
| 23 | Effect.gen(function* () { |
| 24 | const getCluster = yield* GCP.Dataproc.GetCluster(Jobs); |
| 25 | const submitJob = yield* GCP.Dataproc.SubmitJob(Jobs); |
| 26 | |
| 27 | return { |
| 28 | fetch: serveProbes({ |
| 29 | getCluster: getCluster(), |
| 30 | submitJob: submitJob({ |
| 31 | body: { job: { pigJob: { queryList: { queries: ["DUMP;"] } } } }, |
| 32 | }), |
| 33 | }), |
| 34 | }; |
| 35 | }).pipe( |
| 36 | Effect.provide(GCP.Dataproc.GetClusterHttp), |
| 37 | Effect.provide(GCP.Dataproc.SubmitJobHttp), |
| 38 | ), |
| 39 | ) {} |