| 1 | import type * as Effect from "effect/Effect"; |
| 2 | import * as Binding from "../../Binding.ts"; |
| 3 | import type { ReadClient } from "../../Redis/index.ts"; |
| 4 | import type { Instance } from "./Instance.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Bind a Memorystore {@link Instance} with read access. |
| 8 | * |
| 9 | * Uses the shared `alchemy/Redis` RESP client. Provide |
| 10 | * {@link ReadRedisHttp}. The host receives only the instance endpoint; when |
| 11 | * AUTH is enabled the runtime fetches the AUTH string with |
| 12 | * `instances.getAuthString`, so the host is granted `roles/redis.admin` |
| 13 | * (the only predefined role with that permission) on the project under an |
| 14 | * IAM Condition matching this instance. |
| 15 | * |
| 16 | * ### Read |
| 17 | * **Example:** Get a key |
| 18 | * ```typescript |
| 19 | * const cache = yield* GCP.Redis.ReadRedis(Memorystore); |
| 20 | * const value = yield* cache.get("marker"); |
| 21 | * ``` |
| 22 | * |
| 23 | * @binding |
| 24 | * @category Redis |
| 25 | */ |
| 26 | export interface ReadRedis extends Binding.Service< |
| 27 | ReadRedis, |
| 28 | "GCP.Redis.ReadRedis", |
| 29 | (instance: Instance) => Effect.Effect<ReadRedisClient> |
| 30 | > {} |
| 31 | |
| 32 | export const ReadRedis = Binding.Service<ReadRedis>("GCP.Redis.ReadRedis"); |
| 33 | |
| 34 | export type ReadRedisClient = ReadClient; |