@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 60 lines 2.17 KB
Raw
1 import * as Binding from "alchemy/Binding";
2 import type { Input } from "alchemy/Input";
3 import type { RuntimeContext } from "alchemy/RuntimeContext";
4 import type * as Effect from "effect/Effect";
5 import { connectEnvPrefix as makeConnectEnvPrefix } from "../Connection/internal.ts";
6 import type { SecurityGroupId } from "../EC2/SecurityGroup.ts";
7 import type { SubnetId } from "../EC2/Subnet.ts";
8 import type { ReplicationGroup } from "./ReplicationGroup.ts";
9
10 export interface ReplicationGroupConnectionInfo {
11 host: string;
12 port: number;
13 readerHost: string | undefined;
14 readerPort: number | undefined;
15 tls: boolean;
16 }
17
18 export interface ConnectReplicationGroupOptions {
19 subnetIds?: Input<SubnetId[]>;
20 securityGroupIds?: Input<SecurityGroupId[]>;
21 }
22
23 export const replicationGroupConnectEnvPrefix = (logicalId: string) =>
24 makeConnectEnvPrefix("ELASTICACHE", logicalId);
25
26 /**
27 * Runtime binding for a provisioned Valkey or Redis OSS replication group.
28 *
29 * At deploy time it publishes the primary endpoint and TLS setting as
30 * `ELASTICACHE_{LOGICAL_ID}_{HOST,PORT,TLS}` variables on the host Function.
31 * When replicas exist, it also publishes the reader endpoint. Passing VPC
32 * options attaches the host Lambda to the cache network. ElastiCache data
33 * plane access is controlled by security groups, not IAM.
34 *
35 * ### Connecting from a Lambda
36 * **Example:** Use the primary endpoint with iovalkey
37 * ```typescript
38 * const connect = yield* AWS.ElastiCache.ConnectReplicationGroup(cache, {
39 * subnetIds: privateSubnetIds,
40 * securityGroupIds: [functionSecurityGroup.groupId],
41 * });
42 *
43 * // inside the handler:
44 * const { host, port, tls } = yield* connect;
45 * const client = new Valkey({ host, port, ...(tls ? { tls: {} } : {}) });
46 * ```
47 *
48 * @binding
49 */
50 export interface ConnectReplicationGroup extends Binding.Service<
51 ConnectReplicationGroup,
52 "AWS.ElastiCache.ConnectReplicationGroup",
53 (
54 group: ReplicationGroup,
55 options?: ConnectReplicationGroupOptions,
56 ) => Effect.Effect<Effect.Effect<ReplicationGroupConnectionInfo, never, RuntimeContext>>
57 > {}
58 export const ConnectReplicationGroup = Binding.Service<ConnectReplicationGroup>(
59 "AWS.ElastiCache.ConnectReplicationGroup",
60 );