UsageLimit
Source:
src/Railway/Usage.ts
A Railway.UsageLimit is a soft/hard dollar cap on a workspace
customer. One limit per customer. usageLimitRemove is idempotent.
Query usage
Section titled “Query usage”usage is a catalog helper — not a resource. It returns
aggregated rows for the current workspace (or a project).
const rows = yield* Railway.usage({ measurements: ["CPU_USAGE", "MEMORY_USAGE_GB"],});Set a limit
Section titled “Set a limit”Omit workspace / project to cap the current token workspace. A
number is the soft dollar cap.
Soft cap
const cap = yield* Railway.UsageLimit("SpendCap", { limit: 50,});Soft and hard
const cap = yield* Railway.UsageLimit("SpendCap", { project: site, limit: { softLimitDollars: 50, hardLimitDollars: 100 },});Module-scope declarations
Section titled “Module-scope declarations”Resource-valued props accept the resource or an Effect producing it.
import * as Railway from "alchemy/Railway";
export const Site = Railway.Project("Site");export const SpendCap = Railway.UsageLimit("SpendCap", { project: Site, limit: 50,});