Skip to content

Rivet.Fly reference

Source: packages/rivet/src/Fly/MachineControlPlane.ts

A Rivet control plane on Fly.io, as a Rivet.Cluster Layer: an App of engine Machines, each with a volume of its own, a Tigris bucket for the durable copy of every actor’s data, and the App’s public https://{app}.fly.dev address in front. Engines find each other through the bucket and talk over the App’s private network. A namespace is created for the stage.

Pools of nodes anywhere reach it at its public address — RivetFly.MachinePool on Fly, or a pool on any other cloud.

MachineControlPlane: Running a control plane on Fly

Section titled “MachineControlPlane: Running a control plane on Fly”

Three engines in Ashburn

export const Cluster = RivetFly.MachineControlPlane("Rivet");

Larger engines in Frankfurt

export const Cluster = RivetFly.MachineControlPlane("Rivet", {
region: "fra",
guest: { cpus: 4, memoryMb: 8192 },
diskSize: 50,
});

Source: packages/rivet/src/Fly/MachinePool.ts

Run a pool’s nodes on Fly.io: a pool on the control plane, and a private Fly Service whose Machines host every Rivet.DurableObject given this pool. Nodes only connect out to the control plane, so the Service takes no traffic and works with any control plane it can reach — RivetFly.MachineControlPlane, RivetCloud.ControlPlane, or one on another cloud.

Every Durable Object given the same pool shares its nodes: declare the pool once and provide it to each class.

MachinePool: Running Durable Objects on Fly

Section titled “MachinePool: Running Durable Objects on Fly”
export const Cluster = RivetFly.MachineControlPlane("Rivet");
export const Default = RivetFly.MachinePool("Default", { replicas: 2 }).pipe(
Layer.provide(Cluster),
);

Source: packages/rivet/src/Fly/ServicesPool.ts

Run Rivet Services on Fly Machines: the services pool on the control plane, and Machines running Rivet’s prebuilt Services node, which hosts Durable Streams and agentOS. The Machines take no traffic from Fly’s proxy and only connect out: callers reach every stream through the control plane’s gateway, with its token. Works with any control plane it can reach.

ServicesPool: Running Rivet Services on Fly

Section titled “ServicesPool: Running Rivet Services on Fly”
export const Cluster = RivetFly.MachineControlPlane("Rivet");
export const Services = RivetFly.ServicesPool("Services").pipe(Layer.provide(Cluster));