@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, 06:00 UTC

main
ts 61 lines 1.78 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 /** Instance GetInstance / GetCluster are granted on. */
6 export const Db = GCP.Bigtable.Instance("Db", {
7 clusters: {
8 cluster: {
9 location: "us-central1-b",
10 serveNodes: 1,
11 defaultStorageType: "HDD",
12 },
13 },
14 });
15
16 /** The instance's cluster, managed as its own resource. */
17 export const Nodes = Effect.gen(function* () {
18 const instance = yield* Db;
19 return yield* GCP.Bigtable.Cluster("Nodes", {
20 instance: instance.name,
21 clusterId: "cluster",
22 location: "us-central1-b",
23 serveNodes: 1,
24 defaultStorageType: "HDD",
25 });
26 });
27
28 /** Table GetTable is granted on. */
29 export const Rows = Effect.gen(function* () {
30 const instance = yield* Db;
31 return yield* GCP.Bigtable.Table("Rows", {
32 instance: instance.name,
33 columnFamilies: { cf: { gcRule: { maxNumVersions: 1 } } },
34 });
35 });
36
37 /**
38 * Effect-native Cloud Run service exercising every Bigtable binding as its
39 * own runtime service account. Deployed from {@link ../Bindings.test.ts}.
40 */
41 export default class BigtableBindingsHost extends GCP.Function<BigtableBindingsHost>()(
42 "BigtableBindingsHost",
43 { main: import.meta.url, invokerIamDisabled: true },
44 Effect.gen(function* () {
45 const getInstance = yield* GCP.Bigtable.GetInstance(Db);
46 const getCluster = yield* GCP.Bigtable.GetCluster(Nodes);
47 const getTable = yield* GCP.Bigtable.GetTable(Rows);
48
49 return {
50 fetch: serveProbes({
51 getInstance: getInstance(),
52 getCluster: getCluster(),
53 getTable: getTable(),
54 }),
55 };
56 }).pipe(
57 Effect.provide(GCP.Bigtable.GetInstanceHttp),
58 Effect.provide(GCP.Bigtable.GetClusterHttp),
59 Effect.provide(GCP.Bigtable.GetTableHttp),
60 ),
61 ) {}