Preskoči na vsebino

std-rate-limiter

Level: Atom | Entity: RateBucket | Persistence: runtime

2 states, 4 events, 6 transitions

Live Preview

orbital RateBucketOrbital {
entity RateBucket [runtime] {
id : string
name : string
description : string
status : string
createdAt : string
count : number
window : number
limiterStatus : string
}
trait RateBucketRateLimiter -> RateBucket [interaction] {
initial: open
state open {
INIT -> open
(render-ui main { type: "stack", direction: "vertical", gap: "lg", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", justify: "space-between", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", children: [{ type: "icon", name: "shield", size: "lg" }, { type: "typography", content: "RateBucket Rate Limiter", variant: "h2" }] }, { type: "status-dot", status: "success", pulse: false, label: "Open" }] }, { type: "divider" }, { type: "simple-grid", columns: 2, children: [{ type: "stat-display", label: "Requests", value: ["object/get", ["array/first", "@entity"], "count"] }, { type: "stat-display", label: "Window", value: ["object/get", ["array/first", "@entity"], "window"] }] }, { type: "meter", value: ["object/get", ["array/first", "@entity"], "count"], min: 0, max: 100 }, { type: "progress-bar", value: ["object/get", ["array/first", "@entity"], "count"], max: 100, showPercentage: true }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Request", event: "REQUEST", variant: "primary", icon: "send" }, { type: "button", label: "Reset", event: "RESET", variant: "ghost", icon: "rotate-ccw" }] }] })
REQUEST -> open
(render-ui main { type: "stack", direction: "vertical", gap: "lg", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", justify: "space-between", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", children: [{ type: "icon", name: "shield", size: "lg" }, { type: "typography", content: "RateBucket Rate Limiter", variant: "h2" }] }, { type: "status-dot", status: "success", pulse: false, label: "Open" }] }, { type: "divider" }, { type: "simple-grid", columns: 2, children: [{ type: "stat-display", label: "Requests", value: ["object/get", ["array/first", "@entity"], "count"] }, { type: "stat-display", label: "Window", value: ["object/get", ["array/first", "@entity"], "window"] }] }, { type: "meter", value: ["object/get", ["array/first", "@entity"], "count"], min: 0, max: 100 }, { type: "progress-bar", value: ["object/get", ["array/first", "@entity"], "count"], max: 100, showPercentage: true }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Request", event: "REQUEST", variant: "primary", icon: "send" }, { type: "button", label: "Reset", event: "RESET", variant: "ghost", icon: "rotate-ccw" }] }] })
THROTTLE -> throttled
(set @entity.limiterStatus throttled)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", justify: "space-between", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", children: [{ type: "icon", name: "shield", size: "lg" }, { type: "typography", content: "RateBucket Rate Limiter", variant: "h2" }] }, { type: "status-dot", status: "error", pulse: true, label: "Throttled" }] }, { type: "divider" }, { type: "alert", variant: "danger", message: "Rate limit exceeded. Requests are being throttled." }, { type: "simple-grid", columns: 2, children: [{ type: "stat-display", label: "Requests", value: ["object/get", ["array/first", "@entity"], "count"] }, { type: "stat-display", label: "Window", value: ["object/get", ["array/first", "@entity"], "window"] }] }, { type: "meter", value: ["object/get", ["array/first", "@entity"], "count"], min: 0, max: 100 }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Reset", event: "RESET", variant: "primary", icon: "rotate-ccw" }] }] })
RESET -> open
(set @entity.count 0)
(set @entity.limiterStatus open)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", justify: "space-between", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", children: [{ type: "icon", name: "shield", size: "lg" }, { type: "typography", content: "RateBucket Rate Limiter", variant: "h2" }] }, { type: "status-dot", status: "success", pulse: false, label: "Open" }] }, { type: "divider" }, { type: "simple-grid", columns: 2, children: [{ type: "stat-display", label: "Requests", value: ["object/get", ["array/first", "@entity"], "count"] }, { type: "stat-display", label: "Window", value: ["object/get", ["array/first", "@entity"], "window"] }] }, { type: "meter", value: ["object/get", ["array/first", "@entity"], "count"], min: 0, max: 100 }, { type: "progress-bar", value: ["object/get", ["array/first", "@entity"], "count"], max: 100, showPercentage: true }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Request", event: "REQUEST", variant: "primary", icon: "send" }, { type: "button", label: "Reset", event: "RESET", variant: "ghost", icon: "rotate-ccw" }] }] })
}
state throttled {
RESET -> open
(set @entity.limiterStatus open)
(set @entity.count 0)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", justify: "space-between", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", children: [{ type: "icon", name: "shield", size: "lg" }, { type: "typography", content: "RateBucket Rate Limiter", variant: "h2" }] }, { type: "status-dot", status: "success", pulse: false, label: "Open" }] }, { type: "divider" }, { type: "simple-grid", columns: 2, children: [{ type: "stat-display", label: "Requests", value: ["object/get", ["array/first", "@entity"], "count"] }, { type: "stat-display", label: "Window", value: ["object/get", ["array/first", "@entity"], "window"] }] }, { type: "meter", value: ["object/get", ["array/first", "@entity"], "count"], min: 0, max: 100 }, { type: "progress-bar", value: ["object/get", ["array/first", "@entity"], "count"], max: 100, showPercentage: true }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Request", event: "REQUEST", variant: "primary", icon: "send" }, { type: "button", label: "Reset", event: "RESET", variant: "ghost", icon: "rotate-ccw" }] }] })
INIT -> throttled
(render-ui main { type: "stack", direction: "vertical", gap: "lg", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", justify: "space-between", children: [{ type: "stack", direction: "horizontal", gap: "md", align: "center", children: [{ type: "icon", name: "shield", size: "lg" }, { type: "typography", content: "RateBucket Rate Limiter", variant: "h2" }] }, { type: "status-dot", status: "error", pulse: true, label: "Throttled" }] }, { type: "divider" }, { type: "alert", variant: "danger", message: "Rate limit exceeded. Requests are being throttled." }, { type: "simple-grid", columns: 2, children: [{ type: "stat-display", label: "Requests", value: ["object/get", ["array/first", "@entity"], "count"] }, { type: "stat-display", label: "Window", value: ["object/get", ["array/first", "@entity"], "window"] }] }, { type: "meter", value: ["object/get", ["array/first", "@entity"], "count"], min: 0, max: 100 }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Reset", event: "RESET", variant: "primary", icon: "rotate-ccw" }] }] })
}
}
page "/ratebuckets/rate-limiter" -> RateBucketRateLimiter
}
Loading preview...

Orbital Visualization

Loading visualization...

Entity Fields

FieldTypeDefault
idstring-
namestring-
descriptionstring-
statusstring"active"
createdAtstring-
countnumber0
windownumber0
limiterStatusstring"open"

States

StateType
openInitial
throttled-

Events

EventPayload
INIT-
REQUEST-
THROTTLE-
RESET-

Transitions

FromEventToEffects
openINITopen1 effect
openREQUESTopen1 effect
openTHROTTLEthrottled2 effects
throttledRESETopen3 effects
throttledINITthrottled1 effect
openRESETopen3 effects