| 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 | export interface RegisterInstanceRequest extends Omit< |
| 7 | SD.RegisterInstanceRequest, |
| 8 | "ServiceId" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `servicediscovery:RegisterInstance` — lets a |
| 13 | * self-registering workload create or update its own Cloud Map instance |
| 14 | * (an upsert on the instance ID). |
| 15 | * |
| 16 | * The response carries an `OperationId`; registration completes |
| 17 | * asynchronously on the Cloud Map side. |
| 18 | * ### Registering Instances |
| 19 | * **Example:** Self-register on Startup |
| 20 | * ```typescript |
| 21 | * const registerInstance = yield* AWS.CloudMap.RegisterInstance(service); |
| 22 | * |
| 23 | * yield* registerInstance({ |
| 24 | * InstanceId: "worker-1", |
| 25 | * Attributes: { AWS_INSTANCE_IPV4: "10.0.1.10" }, |
| 26 | * }); |
| 27 | * ``` |
| 28 | * |
| 29 | * @binding |
| 30 | */ |
| 31 | export interface RegisterInstance extends Binding.Service< |
| 32 | RegisterInstance, |
| 33 | "AWS.CloudMap.RegisterInstance", |
| 34 | <S extends Service>( |
| 35 | service: S, |
| 36 | ) => Effect.Effect< |
| 37 | ( |
| 38 | request: RegisterInstanceRequest, |
| 39 | ) => Effect.Effect<SD.RegisterInstanceResponse, SD.RegisterInstanceError> |
| 40 | > |
| 41 | > {} |
| 42 | export const RegisterInstance = Binding.Service<RegisterInstance>( |
| 43 | "AWS.CloudMap.RegisterInstance", |
| 44 | ); |