Fly
Host your Durable Objects on Fly.io, and the control plane runs on Fly Machines with a volume each, behind the App’s fly.dev address. Each pool is a private Fly Service, and any Fly Service calls the rooms by name.
import * as RivetFly from "@alchemy.run/rivet/Fly";import * as Layer from "effect/Layer";
export const Cluster = RivetFly.MachineControlPlane("Rivet");
export const Default = RivetFly.MachinePool("Default").pipe(Layer.provide(Cluster));Install @alchemy.run/fly and finish Fly setup.
The control plane
Section titled “The control plane”You get three engine Machines, each with a volume, sharing a Tigris bucket. The App’s fly.dev address is the endpoint.
export const Cluster = RivetFly.MachineControlPlane("Rivet", { region: "fra", guest: { cpus: 4, memoryMb: 8192 }, diskSize: 50,});The pool
Section titled “The pool”export const Default = RivetFly.MachinePool("Default", { replicas: 2, region: "fra" }).pipe( Layer.provide(Cluster),);The pool has no public address.
Rivet Services
Section titled “Rivet Services”ServicesPool runs Rivet Services on Fly Machines that take no traffic from Fly’s proxy:
export const Services = RivetFly.ServicesPool("Services").pipe(Layer.provide(Cluster));Call it from a Fly Service
Section titled “Call it from a Fly Service”export default class Api extends Fly.Service<Api>()( "Api", { main: import.meta.url }, Effect.gen(function* () { const rooms = yield* Room; return { fetch: Effect.gen(function* () { const visitors = yield* rooms.getByName("lobby").join(); return yield* HttpServerResponse.json({ visitors }); }), }; }),) {}Every option, with its default, is in the reference: MachineControlPlane, MachinePool and ServicesPool.