| 1 | import type * as glue from "@distilled.cloud/aws/glue"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Crawler } from "./Crawler.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Runtime binding for `glue:GetCrawler`. |
| 8 | * |
| 9 | * Reads the bound {@link Crawler}'s metadata — most usefully its `State` |
| 10 | * (`READY`, `RUNNING`, `STOPPING`) and `LastCrawl` outcome — so runtime code |
| 11 | * can poll a crawl started with `StartCrawler` to completion. The crawler |
| 12 | * name is injected from the binding. Provide the implementation with |
| 13 | * `Effect.provide(AWS.Glue.GetCrawlerHttp)`. |
| 14 | * ### Running Crawlers |
| 15 | * **Example:** Poll a Crawl to Completion |
| 16 | * ```typescript |
| 17 | * // init |
| 18 | * const startCrawler = yield* AWS.Glue.StartCrawler(crawler); |
| 19 | * const getCrawler = yield* AWS.Glue.GetCrawler(crawler); |
| 20 | * |
| 21 | * // runtime |
| 22 | * yield* startCrawler(); |
| 23 | * const done = yield* getCrawler().pipe( |
| 24 | * Effect.repeat({ |
| 25 | * schedule: Schedule.spaced("10 seconds"), |
| 26 | * until: (r) => r.Crawler?.State === "READY", |
| 27 | * times: 8, |
| 28 | * }), |
| 29 | * ); |
| 30 | * ``` |
| 31 | * |
| 32 | * @binding |
| 33 | */ |
| 34 | export interface GetCrawler extends Binding.Service< |
| 35 | GetCrawler, |
| 36 | "AWS.Glue.GetCrawler", |
| 37 | ( |
| 38 | crawler: Crawler, |
| 39 | ) => Effect.Effect< |
| 40 | () => Effect.Effect<glue.GetCrawlerResponse, glue.GetCrawlerError> |
| 41 | > |
| 42 | > {} |
| 43 | |
| 44 | export const GetCrawler = Binding.Service<GetCrawler>("AWS.Glue.GetCrawler"); |