lambda

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package lambda is doze-aws's local AWS Lambda: functions run as supervised local processes speaking the Lambda Runtime API (no Docker). It implements the control plane (create/update/get/list/delete, versions, aliases, concurrency, DLQ/destinations, tags), synchronous and async Invoke, function URLs, and SQS event source mappings that poll a queue and deliver batches.

Code packaging: ZipFile (unpacked to the data dir) and a doze extension where Code.S3Bucket == "_local_" and Code.S3Key is an absolute path to a directory or binary used in place (edit-and-reinvoke, no copy).

Runtime = a per-function concurrency pool of supervised processes that grows with demand (capped) and scales back to zero after an idle window, so an unused function holds no processes. See docs/api-support/lambda.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventSourceMapping

type EventSourceMapping struct {
	UUID           string `json:"uuid"`
	FunctionName   string `json:"function_name"`
	EventSourceArn string `json:"event_source_arn"`
	BatchSize      int    `json:"batch_size"`
	Enabled        bool   `json:"enabled"`
	State          string `json:"state"` // Enabled | Disabled
}

EventSourceMapping is one SQS→function poller definition.

type Function

type Function struct {
	Name        string            `json:"name"`
	Runtime     string            `json:"runtime"`
	Handler     string            `json:"handler"`
	Role        string            `json:"role,omitempty"`
	Description string            `json:"description,omitempty"`
	Timeout     int               `json:"timeout"` // seconds
	MemorySize  int               `json:"memory_size"`
	Env         map[string]string `json:"env,omitempty"`
	Command     []string          `json:"command,omitempty"` // doze extension

	// Code location: either an unpacked dir under the data dir, or an
	// in-place absolute path (the _local_ bucket convention).
	CodeDir    string `json:"code_dir"`
	CodeSHA256 string `json:"code_sha256,omitempty"`
	Version    string `json:"version"` // "$LATEST" or a published number

	DeadLetterArn       string            `json:"dead_letter_arn,omitempty"`
	Destinations        json.RawMessage   `json:"destinations,omitempty"` // DestinationConfig round-trip
	ReservedConcurrency *int              `json:"reserved_concurrency,omitempty"`
	Tags                map[string]string `json:"tags,omitempty"`
	Layers              []string          `json:"layers,omitempty"`

	// EventInvokeConfig (async): set via PutFunctionEventInvokeConfig; the
	// presence of any of these means an event-invoke config exists.
	MaxRetryAttempts   *int `json:"max_retry_attempts,omitempty"`
	MaxEventAgeSeconds *int `json:"max_event_age_seconds,omitempty"`
	HasEventInvokeCfg  bool `json:"has_event_invoke_cfg,omitempty"`

	Aliases  map[string]string `json:"aliases,omitempty"` // alias -> version
	LastMod  int64             `json:"last_mod"`
	Revision string            `json:"revision"`

	FunctionURL string `json:"function_url,omitempty"` // when a URL config exists
}

Function is a stored function definition.

func (*Function) ARN

func (f *Function) ARN() string

ARN returns the function ARN.

type Options

type Options struct {
	// DataDir holds the store, unpacked code, and logs. Required.
	DataDir string
	// Peers resolves sibling services: injected as AWS_ENDPOINT_URL_* into
	// function processes, and used by event source mappings to poll SQS.
	Peers peers.Directory
	// Endpoint is the shared gateway URL handlers reach siblings through
	// (AWS_ENDPOINT_URL). Empty derives per-service from Peers where possible.
	Endpoint string
	// Logf receives log lines; nil discards.
	Logf func(format string, args ...any)
	// Clock overrides time.Now in tests.
	Clock func() time.Time
	// IdleTimeout is how long a warm function keeps its process(es) before
	// scaling to zero. Zero uses lambdaruntime.DefaultIdleTimeout.
	IdleTimeout time.Duration
}

Options configures the service.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the Lambda service.

func New

func New(opts Options) (*Server, error)

New opens the store under DataDir.

func (*Server) Close

func (s *Server) Close() error

Close stops every runner and poller and closes the store. It waits for the ESM poller goroutines to actually exit so none can call into sibling services (or log) after Close returns.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is the bbolt-backed Lambda control-plane state.

func (*Store) DeleteFunction

func (s *Store) DeleteFunction(name string) error

DeleteFunction removes a function.

func (*Store) DeleteMapping

func (s *Store) DeleteMapping(uuid string) error

func (*Store) GetFunction

func (s *Store) GetFunction(name string) (*Function, error)

GetFunction loads a function by name.

func (*Store) GetMapping

func (s *Store) GetMapping(uuid string) (*EventSourceMapping, error)

func (*Store) ListFunctions

func (s *Store) ListFunctions() ([]Function, error)

ListFunctions returns all functions, sorted by name.

func (*Store) ListMappings

func (s *Store) ListMappings() ([]EventSourceMapping, error)

func (*Store) PutFunction

func (s *Store) PutFunction(f *Function) error

PutFunction stores a function.

func (*Store) PutMapping

func (s *Store) PutMapping(m *EventSourceMapping) error

func (*Store) Update

func (s *Store) Update(name string, fn func(*Function) error) (*Function, error)

Update applies fn to a function.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL