| 1 | import * as GCP from "@/GCP"; |
| 2 | |
| 3 | /** |
| 4 | * Resources the serverless smoke is composed of, shared by the API |
| 5 | * Function, the worker Function, the Job, and the test's stack program. |
| 6 | * Each is declared once; every `yield*` resolves the same logical resource. |
| 7 | */ |
| 8 | |
| 9 | /** Todos, worker results, and every consumer's markers. */ |
| 10 | export const Store = GCP.Firestore.Database("SmokeStore", { |
| 11 | location: "us-central1", |
| 12 | type: "FIRESTORE_NATIVE", |
| 13 | }); |
| 14 | |
| 15 | /** Files uploaded through the API; finalize events fan out via Eventarc. */ |
| 16 | export const Uploads = GCP.Storage.Bucket("SmokeUploads", { |
| 17 | location: "US-CENTRAL1", |
| 18 | forceDestroy: true, |
| 19 | }); |
| 20 | |
| 21 | /** Jobs the API publishes and the worker consumes over push. */ |
| 22 | export const Jobs = GCP.PubSub.Topic("SmokeJobs", {}); |
| 23 | |
| 24 | /** Scheduler job id the worker consumes (yearly: never fires on its own). */ |
| 25 | export const SCHEDULE_ID = "SmokeTick"; |
| 26 | export const SCHEDULE_BODY = "smoke-tick"; |
| 27 | |
| 28 | /** Firestore document ids cannot contain `/`. */ |
| 29 | export const docId = (value: string) => value.replaceAll("/", "_"); |
| 30 | |
| 31 | /** What the API publishes to {@link Jobs}. */ |
| 32 | export interface JobMessage { |
| 33 | id: string; |
| 34 | payload: string; |
| 35 | } |