#Function Runtime
Function runtime state describes the currently restored sandbox serving a function revision. When the source sandbox still exists, Function Gateway routes to it directly. When the source sandbox is gone, Function Gateway restores a runtime sandbox from the revision's template and revision-owned volumes.
Runtime States#
| State | Meaning |
|---|---|
idle | No restored runtime sandbox is currently recorded for the active revision |
active | A restored runtime sandbox is recorded for the active revision |
disabled | The function is disabled and does not serve host traffic |
restart and recycle both delete the current restored runtime sandbox when one exists and clear the runtime mapping. The next function request starts a fresh runtime from the active revision.
Get Runtime Status#
/api/v1/functions/{id}/runtime
goruntime, err := client.GetFunctionRuntime(ctx, functionID) if err != nil { log.Fatal(err) } fmt.Printf("state=%s revision=%d\n", runtime.State, runtime.RevisionNumber)
Restart Runtime#
/api/v1/functions/{id}/runtime/restart
goruntime, err := client.RestartFunctionRuntime(ctx, functionID) if err != nil { log.Fatal(err) } fmt.Printf("state=%s\n", runtime.State)
Recycle Runtime#
/api/v1/functions/{id}/runtime/recycle
goruntime, err := client.RecycleFunctionRuntime(ctx, functionID) if err != nil { log.Fatal(err) } fmt.Printf("state=%s\n", runtime.State)
Disable Serving#
/api/v1/functions/{id}
Disabling a function keeps its identity, domain, revisions, and aliases. Disabled functions return 503 from the function host and do not restore runtime sandboxes.
gofn, err := client.UpdateFunctionWithOptions( ctx, functionID, sandbox0.WithFunctionEnabled(false), ) if err != nil { log.Fatal(err) } fmt.Printf("enabled=%t\n", fn.Enabled)
Delete a Function#
/api/v1/functions/{id}
Delete is a soft delete. The function disappears from normal list/get APIs, the host stops serving traffic, and the slug/domain label remain reserved. Sandbox0 schedules best-effort cleanup for restored runtime sandboxes and revision-owned volumes.
gofn, err := client.DeleteFunction(ctx, functionID) if err != nil { log.Fatal(err) } fmt.Printf("deleted function: %s\n", fn.ID)
Next Steps#
Revisions And Aliases
Move production traffic between immutable function revisions.
Volume Snapshots
Understand the snapshot model used for revision restore mounts.