Documentation/docs/function/runtime

#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#

StateMeaning
idleNo restored runtime sandbox is currently recorded for the active revision
activeA restored runtime sandbox is recorded for the active revision
disabledThe 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#

GET

/api/v1/functions/{id}/runtime

go
runtime, err := client.GetFunctionRuntime(ctx, functionID) if err != nil { log.Fatal(err) } fmt.Printf("state=%s revision=%d\n", runtime.State, runtime.RevisionNumber)

Restart Runtime#

POST

/api/v1/functions/{id}/runtime/restart

go
runtime, err := client.RestartFunctionRuntime(ctx, functionID) if err != nil { log.Fatal(err) } fmt.Printf("state=%s\n", runtime.State)

Recycle Runtime#

POST

/api/v1/functions/{id}/runtime/recycle

go
runtime, err := client.RecycleFunctionRuntime(ctx, functionID) if err != nil { log.Fatal(err) } fmt.Printf("state=%s\n", runtime.State)

Disable Serving#

PUT

/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.

go
fn, err := client.UpdateFunctionWithOptions( ctx, functionID, sandbox0.WithFunctionEnabled(false), ) if err != nil { log.Fatal(err) } fmt.Printf("enabled=%t\n", fn.Enabled)

Delete a Function#

DELETE

/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.

go
fn, 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.