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

main
ts 59 lines 1.94 KB
Raw
1 import * as GCP from "@alchemy.run/gcp";
2 import * as Effect from "effect/Effect";
3 import { serveProbes } from "../../bindingHost.ts";
4
5 export const Brokers = GCP.ManagedKafka.Cluster("Brokers", {
6 location: "us-central1",
7 });
8
9 export const Events = Effect.gen(function* () {
10 const cluster = yield* Brokers;
11 return yield* GCP.ManagedKafka.ClustersTopic("Events", {
12 cluster: cluster.name,
13 });
14 });
15
16 export const Connect = Effect.gen(function* () {
17 const cluster = yield* Brokers;
18 return yield* GCP.ManagedKafka.ConnectCluster("Connect", {
19 kafkaCluster: cluster.name,
20 labels: { env: "test" },
21 });
22 });
23
24 // The Schema Registry API requires a Kafka cluster in the region.
25 export const Schemas = Effect.gen(function* () {
26 const cluster = yield* Brokers;
27 return yield* GCP.ManagedKafka.SchemaRegistry("Schemas", {
28 location: cluster.location,
29 });
30 });
31
32 /**
33 * Effect-native Cloud Run service exercising every Managed Kafka binding as
34 * its own runtime service account. Deployed from {@link ../Bindings.test.ts}.
35 */
36 export default class KafkaBindingsHost extends GCP.Function<KafkaBindingsHost>()(
37 "KafkaBindingsHost",
38 { main: import.meta.url, invokerIamDisabled: true },
39 Effect.gen(function* () {
40 const getCluster = yield* GCP.ManagedKafka.GetCluster(yield* Brokers);
41 const getTopic = yield* GCP.ManagedKafka.GetTopic(yield* Events);
42 const getConnect = yield* GCP.ManagedKafka.GetConnectCluster(yield* Connect);
43 const getRegistry = yield* GCP.ManagedKafka.GetSchemaRegistry(yield* Schemas);
44
45 return {
46 fetch: serveProbes({
47 getCluster: getCluster(),
48 getTopic: getTopic(),
49 getConnectCluster: getConnect(),
50 getSchemaRegistry: getRegistry(),
51 }),
52 };
53 }).pipe(
54 Effect.provide(GCP.ManagedKafka.GetClusterHttp),
55 Effect.provide(GCP.ManagedKafka.GetTopicHttp),
56 Effect.provide(GCP.ManagedKafka.GetConnectClusterHttp),
57 Effect.provide(GCP.ManagedKafka.GetSchemaRegistryHttp),
58 ),
59 ) {}