1import * as Fly from "@/Fly";
2import * as Config from "effect/Config";
3import * as Effect from "effect/Effect";
4import * as HttpServerResponse from "effect/http/HttpServerResponse";
5
6/**
7 * A Service in two regions with a Volume per Machine. It answers with the
8 * region of the Machine that served the request.
9 */
10export default class RegionalApi extends Fly.Service<RegionalApi>()(
11 "RegionalApi",
12 {
13 main: import.meta.url,
14 region: ["iad", "lhr"],
15 guest: { cpuKind: "shared", cpus: 1, memoryMb: 256 },
16 },
17 Effect.gen(function* () {
18 yield* Fly.MountVolume({ path: "/data", sizeGb: 1 });
19 return {
20 fetch: Effect.gen(function* () {
21 return HttpServerResponse.text(yield* Config.String("FLY_REGION"));
22 }).pipe(Effect.orDie),
23 };
24 }).pipe(Effect.provide(Fly.MountVolumeLive)),
25) {}