| 1 | import type * as SD from "@distilled.cloud/aws/servicediscovery"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Service } from "./Service.ts"; |
| 5 | |
| 6 | /** |
| 7 | * `GetInstancesHealthStatus` request with `ServiceId` injected from the |
| 8 | * bound {@link Service}. |
| 9 | */ |
| 10 | export interface GetInstancesHealthStatusRequest extends Omit< |
| 11 | SD.GetInstancesHealthStatusRequest, |
| 12 | "ServiceId" |
| 13 | > {} |
| 14 | |
| 15 | /** |
| 16 | * Runtime binding for `servicediscovery:GetInstancesHealthStatus` — reads |
| 17 | * the current health status (`HEALTHY`, `UNHEALTHY`, or `UNKNOWN`) of the |
| 18 | * bound {@link Service}'s instances. There is a brief delay between |
| 19 | * registering an instance and its health status becoming available. |
| 20 | * Provide the implementation with |
| 21 | * `Effect.provide(AWS.CloudMap.GetInstancesHealthStatusHttp)`. |
| 22 | * ### Instance Health |
| 23 | * **Example:** Read Health of All Instances |
| 24 | * ```typescript |
| 25 | * const getInstancesHealthStatus = |
| 26 | * yield* AWS.CloudMap.GetInstancesHealthStatus(service); |
| 27 | * |
| 28 | * const { Status } = yield* getInstancesHealthStatus(); |
| 29 | * console.log(Status?.["worker-1"]); // "HEALTHY" | "UNHEALTHY" | "UNKNOWN" |
| 30 | * ``` |
| 31 | * |
| 32 | * **Example:** Read Health of Specific Instances |
| 33 | * ```typescript |
| 34 | * const { Status } = yield* getInstancesHealthStatus({ |
| 35 | * Instances: ["worker-1", "worker-2"], |
| 36 | * }); |
| 37 | * ``` |
| 38 | * |
| 39 | * @binding |
| 40 | */ |
| 41 | export interface GetInstancesHealthStatus extends Binding.Service< |
| 42 | GetInstancesHealthStatus, |
| 43 | "AWS.CloudMap.GetInstancesHealthStatus", |
| 44 | <S extends Service>( |
| 45 | service: S, |
| 46 | ) => Effect.Effect< |
| 47 | ( |
| 48 | request?: GetInstancesHealthStatusRequest, |
| 49 | ) => Effect.Effect< |
| 50 | SD.GetInstancesHealthStatusResponse, |
| 51 | SD.GetInstancesHealthStatusError |
| 52 | > |
| 53 | > |
| 54 | > {} |
| 55 | export const GetInstancesHealthStatus = |
| 56 | Binding.Service<GetInstancesHealthStatus>( |
| 57 | "AWS.CloudMap.GetInstancesHealthStatus", |
| 58 | ); |