| 1 | import type * as kafka from "@distilled.cloud/aws/kafka"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { ServerlessCluster } from "./ServerlessCluster.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Runtime binding for the `GetBootstrapBrokers` operation (IAM action |
| 8 | * `kafka:GetBootstrapBrokers`), scoped to one {@link ServerlessCluster}. |
| 9 | * |
| 10 | * Resolves the cluster's bootstrap broker connection strings at runtime — |
| 11 | * for MSK Serverless the SASL/IAM string |
| 12 | * (`BootstrapBrokerStringSaslIam`) is the one Kafka clients connect to. |
| 13 | * Provide the implementation with |
| 14 | * `Effect.provide(AWS.Kafka.GetBootstrapBrokersHttp)`. |
| 15 | * ### Connecting to a Cluster |
| 16 | * **Example:** Resolve the SASL/IAM Bootstrap Brokers |
| 17 | * ```typescript |
| 18 | * const getBootstrapBrokers = yield* Kafka.GetBootstrapBrokers(cluster); |
| 19 | * |
| 20 | * const brokers = yield* getBootstrapBrokers(); |
| 21 | * // brokers.BootstrapBrokerStringSaslIam → "b-1.….kafka-serverless.…:9098" |
| 22 | * ``` |
| 23 | * |
| 24 | * @binding |
| 25 | */ |
| 26 | export interface GetBootstrapBrokers extends Binding.Service< |
| 27 | GetBootstrapBrokers, |
| 28 | "AWS.Kafka.GetBootstrapBrokers", |
| 29 | ( |
| 30 | cluster: ServerlessCluster, |
| 31 | ) => Effect.Effect< |
| 32 | () => Effect.Effect< |
| 33 | kafka.GetBootstrapBrokersResponse, |
| 34 | kafka.GetBootstrapBrokersError |
| 35 | > |
| 36 | > |
| 37 | > {} |
| 38 | export const GetBootstrapBrokers = Binding.Service<GetBootstrapBrokers>( |
| 39 | "AWS.Kafka.GetBootstrapBrokers", |
| 40 | ); |