@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 44 lines 1.62 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 /**
6 * Memcached instances need Private Service Access on the project's default
7 * network (without it create fails with BadRequest "Google private service
8 * access is not enabled.") and take ~10 minutes to provision, so
9 * `GCP_TEST_PRIVATE_SERVICE_ACCESS=1` + `GCP_TEST_SLOW=1` opt in. The gate
10 * is forwarded to the host's environment so the deployed runtime binds the
11 * same set.
12 */
13 export const memcacheEnabled =
14 !!process.env.GCP_TEST_PRIVATE_SERVICE_ACCESS && !!process.env.GCP_TEST_SLOW && !process.env.FAST;
15
16 /** Instance the binding is granted for; declared only when enabled. */
17 export const Cache = GCP.Memcache.Instance("Cache", {
18 location: "us-central1",
19 });
20
21 const instanceProbes = Effect.gen(function* () {
22 const getInstance = yield* GCP.Memcache.GetInstance(Cache);
23 return { getInstance: getInstance() };
24 });
25
26 /**
27 * Effect-native Cloud Run service exercising the Memcache binding as its own
28 * runtime service account. Deployed from {@link ../Bindings.test.ts}.
29 */
30 export default class MemcacheBindingsHost extends GCP.Function<MemcacheBindingsHost>()(
31 "MemcacheBindingsHost",
32 {
33 main: import.meta.url,
34 invokerIamDisabled: true,
35 env: {
36 GCP_TEST_PRIVATE_SERVICE_ACCESS: memcacheEnabled ? "1" : "",
37 GCP_TEST_SLOW: memcacheEnabled ? "1" : "",
38 },
39 },
40 Effect.gen(function* () {
41 const instance = memcacheEnabled ? yield* instanceProbes : {};
42 return { fetch: serveProbes({ ...instance }) };
43 }).pipe(Effect.provide(GCP.Memcache.GetInstanceHttp)),
44 ) {}