Rivet.layerObjectHost reference
layerObjectHost
Section titled “layerObjectHost”Source:
packages/rivet/src/ObjectHost.tsKind: Layer · Provides:ObjectHost
Objects on Rivet. Every class declared on it is held by one Durable Object
class, name: the object a-1 of the class Bank.AccountAggregate is the
instance Bank.AccountAggregate/a-1, with its own SQLite and alarm.
Built in a caller (a Worker, a container), the Layer deploys that class to
pool and reaches it through the control plane’s gateway. The pool’s
nodes load the Layer built on this one from main, and there the same
Layer holds the class.
It is the entrypoint of everything built on objects: provide it once, to
the Layer the module exports as its default. DomainRivet.layerDurableObjects()
puts a Domain model on it, and AI.layerObjects a process’s sessions.
layerObjectHost: Examples
Section titled “layerObjectHost: Examples”import * as AI from "@alchemy.run/ai";import * as DomainRivet from "@alchemy.run/domain/Rivet";import * as Rivet from "@alchemy.run/rivet";import * as RivetDocker from "@alchemy.run/rivet/Docker";import * as Layer from "effect/Layer";import { Harness } from "./Harness.ts";import { Board, IssueWorkLive } from "./Board.model.ts";import { TriageLive } from "./Triage.process.ts";
const ControlPlane = RivetDocker.SwarmControlPlane("Rivet");const Default = RivetDocker.SwarmPool("Default").pipe(Layer.provide(ControlPlane));
const BoardLive = Board.layer(IssueWorkLive).pipe(Layer.provide(DomainRivet.layerDurableObjects()));
const TriageSessions = AI.layerObjects( TriageLive.pipe(Layer.provide(Layer.mergeAll(Harness, BoardLive))),);
export default BoardLive.pipe( Layer.provideMerge(TriageSessions), Layer.provide(Rivet.layerObjectHost("App", { main: import.meta.url, pool: Default })),);