Documentation
¶
Overview ¶
Package lambdaruntime runs Lambda functions as supervised local processes that speak the AWS Lambda Runtime API. Each function gets one child process (serial invocations in this phase) started with AWS_LAMBDA_RUNTIME_API pointing at a per-function loopback listener serving the four runtime routes:
GET /2018-06-01/runtime/invocation/next
POST /2018-06-01/runtime/invocation/{id}/response
POST /2018-06-01/runtime/invocation/{id}/error
POST /2018-06-01/runtime/init/error
The official runtime interface clients (provided.al2 bootstrap, awslambdaric for Python/Node) speak this protocol unmodified — so real handlers run with no Docker.
Index ¶
Constants ¶
const DefaultIdleTimeout = 10 * time.Minute
DefaultIdleTimeout is how long a fully-idle pool keeps its warm child processes before reaping them to zero. Long enough that active development keeps warm-start latency, short enough that a walked-away-from stack releases the memory. AWS reaps idle execution environments on a similar horizon.
const DefaultPoolMax = 5
DefaultPoolMax is the concurrency ceiling for a function with no reserved concurrency configured — how many child processes can run its invocations at once. Kept modest so a local stack doesn't fork a process per request.
Variables ¶
var ErrPoolClosed = errors.New("lambda pool closed")
ErrPoolClosed is returned by Invoke when the pool has been stopped (e.g. a concurrent restart). Callers may retry against a freshly-created pool.
Functions ¶
This section is empty.
Types ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool runs a function's invocations across a growable set of Runners (one child process each), giving up to Max concurrent executions. It grows lazily to match observed concurrency and never exceeds Max — the local analogue of Lambda's per-function concurrency. Under serial load it stays at one Runner.
When the pool goes fully idle (no invocation in flight) it scales back to zero after idleTimeout: every warm process is stopped and the next invoke spawns a fresh one. So a function you stop calling stops costing memory.
func (*Pool) IdleTimeout ¶ added in v0.2.0
IdleTimeout returns the pool's scale-to-zero window.
func (*Pool) Invoke ¶
Invoke runs one invocation on a pooled Runner, spawning another (up to Max) when concurrent demand exceeds the current pool size.
func (*Pool) SetIdleTimeout ¶ added in v0.2.0
SetIdleTimeout overrides how long a fully-idle pool stays warm before it scales to zero. A value <= 0 restores DefaultIdleTimeout. Safe to call before the pool is first used.
func (*Pool) SleepDeadline ¶ added in v0.2.0
SleepDeadline reports when the warm pool will scale to zero and whether a countdown is currently running (true only when warm and idle). It returns the zero time and false when the pool is cold or actively executing.
type Result ¶
type Result struct {
Payload []byte
FunctionErr string // non-empty on a handler error (X-Amz-Function-Error)
Logs []byte // tail of stdout/stderr
}
Result is one invocation's outcome.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner supervises one function's process and Runtime API listener.
type Spec ¶
type Spec struct {
Name string
Handler string
Runtime string // provided.*, go, python3.x, nodejs*
Command []string // explicit command (doze extension) — wins over Runtime mapping
Dir string // working directory
Env map[string]string // function environment
Timeout time.Duration
Endpoints map[string]string // AWS_ENDPOINT_URL_* injected so handlers reach sibling services
}
Spec describes how to run one function.