| 1 | import * as Cloudflare from "alchemy/Cloudflare"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as HttpServerResponse from "effect/http/HttpServerResponse"; |
| 4 | |
| 5 | /** |
| 6 | * Minimal Effect-native container for the cold-start benchmark. Alchemy bundles |
| 7 | * this file's Effect program into a generated image; the DO proxies a trivial |
| 8 | * `ping()` RPC into it, which is enough to prove the container is up and |
| 9 | * accepting connections on its RPC port. |
| 10 | */ |
| 11 | export class EffectfulContainer extends Cloudflare.Container< |
| 12 | EffectfulContainer, |
| 13 | { |
| 14 | ping: () => Effect.Effect<string>; |
| 15 | } |
| 16 | >()("BenchEffectfulContainer") {} |
| 17 | |
| 18 | export default EffectfulContainer.make( |
| 19 | { |
| 20 | main: import.meta.filename, |
| 21 | image: "oven/bun:latest", |
| 22 | // Match wrangler's container config so the comparison isolates the |
| 23 | // framework, not the tier: max_instances 100 (Alchemy defaults to 1), |
| 24 | // instance_type "lite", and instances 0 (pure scale-from-zero). |
| 25 | maxInstances: 100, |
| 26 | instanceType: "lite", |
| 27 | instances: 0, |
| 28 | }, |
| 29 | Effect.gen(function* () { |
| 30 | return { |
| 31 | ping: () => Effect.succeed("pong"), |
| 32 | fetch: Effect.succeed(HttpServerResponse.text("ok")), |
| 33 | }; |
| 34 | }), |
| 35 | ); |