1import * as GCP from "@/GCP";
2import * as Config from "effect/Config";
3import * as Effect from "effect/Effect";
4import { Store } from "./serverless-resources.ts";
5
6/**
7 * Effect-native Cloud Run Job the API triggers through `GCP.Run.RunJob`.
8 * Each execution records `executions/{CLOUD_RUN_EXECUTION}` in Firestore.
9 */
10export default class SmokeJob extends GCP.Run.Job<SmokeJob>()(
11 "SmokeJob",
12 { main: import.meta.url, location: "us-central1" },
13 Effect.gen(function* () {
14 const store = yield* GCP.Firestore.WriteDatabase(Store);
15 return {
16 run: Effect.gen(function* () {
17 const execution = yield* Config.String("CLOUD_RUN_EXECUTION");
18 yield* store.set(`executions/${execution}`, {
19 execution,
20 ranAt: new Date(),
21 });
22 }).pipe(Effect.orDie),
23 };
24 }).pipe(Effect.provide(GCP.Firestore.WriteDatabaseHttp)),
25) {}