Documentation
¶
Overview ¶
Package functions is your serverless code: publish it, call it over HTTP, watch every run and what it cost.
The /v1/functions registry is per-org — one function, one owner. Every function belongs to exactly one org (the gateway-minted X-Org-Id, HIP-0026); org isolation is the org column, enforced on every query. The registry stores a function's runtime, source, resource limits, and the NAMES of the secrets it mounts — never a secret value (values live in KMS by reference, the Secret-Manager principle).
Surface (the shape console's FunctionsModule / functions.ts consume):
GET /v1/functions list functions -> {functions:[...]}
POST /v1/functions create / redeploy -> ServerlessFunction
GET /v1/functions/metrics invocations chart + donut -> {series,status,costCents}
GET /v1/functions/triggers all triggers (HTTP) -> {triggers:[...]}
GET /v1/functions/deployments current deployments -> {functions:[...]}
GET /v1/functions/secrets mounted secret NAMES -> {secrets:[...]}
GET /v1/functions/:name detail + triggers + calls -> FunctionDetail
DELETE /v1/functions/:name delete (+ its invocations)
GET /v1/functions/:name/invocations recent invocations -> {invocations:[...]}
GET /v1/functions/:name/logs last invocation output -> {logs:"..."}
POST /v1/functions/:name/invoke run the function {input} -> Invocation
Invoke delegates to the sandboxed code executor (CODE_EXEC_UPSTREAM) — this binary NEVER runs org code in-process. When the sandbox is not configured invoke fails closed (503) and fabricates nothing. Every metric the Overview shows is DERIVED from real invocation rows; there is no invented rollup.
Index ¶
- func Mount(app cloud.Router, deps cloud.Deps) error
- func Shutdown() error
- type Function
- type InvStats
- type Invocation
- type Store
- func (s *Store) Close() error
- func (s *Store) Delete(ctx context.Context, org, name string) (bool, error)
- func (s *Store) Get(ctx context.Context, org, name string) (Function, error)
- func (s *Store) InsertInvocation(ctx context.Context, iv Invocation) error
- func (s *Store) InvocationsSince(ctx context.Context, org string, since int64, limit int) ([]Invocation, error)
- func (s *Store) List(ctx context.Context, org string) ([]Function, error)
- func (s *Store) ListInvocations(ctx context.Context, org, fn string, limit int) ([]Invocation, error)
- func (s *Store) StatsSince(ctx context.Context, org, fn string, since int64) (InvStats, error)
- func (s *Store) Upsert(ctx context.Context, f Function) (Function, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Function ¶
type Function struct {
ID string
Org string
Name string
Namespace string
Runtime string
Image string
Code string
Handler string
Target string // "" = sandbox (default) | "fleet" = org GPU fleet (fn.run)
TimeoutSec int
MemoryLimit string
EnvNames []string
Status string
DeployVer int
CreatedAt int64
LastDeployAt int64
}
Function is the org-scoped definition of a serverless function: a runtime (environment) + source code + resource limits + the NAMES of the secrets it mounts (values live in KMS, never here). Org isolation is the org column.
type Invocation ¶
type Invocation struct {
ID string
Org string
FunctionName string
Status string // ok | error | timeout
StatusCode int
Method string
DurationMs int64
Output string
Error string
CreatedAt int64
}
Invocation is one execution of a function: real history, one row per call.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is one org's functions database — ONE SQLite file per org at {DataDir}/orgs/{orgSlug}/functions.db (opened via cloud.OrgDB). functions is org-scoped (it carries no project axis); org-scoping is PHYSICAL, with the org column retained as defense-in-depth.
func (*Store) Delete ¶
Delete removes a function and its invocation history. Reports whether a row went.
func (*Store) InsertInvocation ¶
func (s *Store) InsertInvocation(ctx context.Context, iv Invocation) error
InsertInvocation records one function execution.
func (*Store) InvocationsSince ¶
func (s *Store) InvocationsSince(ctx context.Context, org string, since int64, limit int) ([]Invocation, error)
InvocationsSince returns raw invocation rows for an org since a unix time (newest first, capped) — the real basis for the metrics chart. One query across all the org's functions; bucketing happens in memory.
func (*Store) ListInvocations ¶
func (s *Store) ListInvocations(ctx context.Context, org, fn string, limit int) ([]Invocation, error)
ListInvocations returns invocation history for (org,function), newest first.
func (*Store) StatsSince ¶
StatsSince returns invocation aggregates for (org,function) since a unix time — the REAL basis for invocations7d / successRate / avgDurationMs. Never a fabricated rollup.