@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 42 lines 1.31 KB
Raw
1 import * as Kubernetes from "@alchemy.run/kubernetes";
2 import * as Output from "alchemy/Output";
3 import * as Effect from "effect/Effect";
4 import * as HttpClient from "effect/http/HttpClient";
5 import * as HttpClientResponse from "effect/http/HttpClientResponse";
6 import * as Schedule from "effect/Schedule";
7 import { Cluster, Namespace, Web } from "./infra.ts";
8
9 export default Kubernetes.Job(
10 "SmokeTest",
11 Effect.gen(function* () {
12 const cluster = yield* Cluster;
13 const namespace = yield* Namespace;
14 return {
15 cluster,
16 main: import.meta.url,
17 name: "smoke-test",
18 namespace: namespace.name,
19 backoffLimit: 2,
20 ttlSecondsAfterFinished: 600,
21 };
22 }),
23 Effect.gen(function* () {
24 const web = yield* Web;
25 const webUrl =
26 yield* Output.interpolate`http://${web.serviceName}.${web.namespace}.svc.cluster.local:${web.port}`;
27
28 return {
29 run: Effect.gen(function* () {
30 const url = yield* webUrl;
31 const response = yield* HttpClient.get(`${url}/healthz`).pipe(
32 Effect.flatMap(HttpClientResponse.filterStatusOk),
33 Effect.retry({
34 schedule: Schedule.exponential("1 second"),
35 times: 5,
36 }),
37 );
38 yield* Effect.log(`${url} responded ${response.status}`);
39 }).pipe(Effect.orDie),
40 };
41 }),
42 );