Documentation
¶
Overview ¶
Package lambda emulates AWS Lambda (REST-JSON): functions, versions, aliases, layers, permissions, function URLs and event source mappings. Python and Node.js handlers run as warm local processes behind an embedded Runtime API client; other runtimes and container images run in Docker.
Index ¶
- func HTTPEvent(r *http.Request, apiID, routeKey string) []byte
- func SDKDir(dataDir string) string
- func WriteHTTPResult(w http.ResponseWriter, result []byte)
- type Alias
- type Config
- type Function
- type ImageConfig
- type InvokeResult
- type Layer
- type LayerVersion
- type Mapping
- type Provisioned
- type Service
- func (s *Service) BodyLimit(r *http.Request) int64
- func (s *Service) Close() error
- func (s *Service) Info() core.Info
- func (s *Service) Inspect(table, id string) any
- func (s *Service) Invoke(account, region, name string, payload []byte) (InvokeResult, error)
- func (s *Service) Links() []core.Link
- func (s *Service) Load(b []byte) error
- func (s *Service) RecentLogs(account, region, name string) []string
- func (s *Service) Reset()
- func (s *Service) Resources() []core.Table
- func (s *Service) Save() ([]byte, error)
- func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Service) TaggedResources(account, region string) map[string]map[string]string
- func (s *Service) Tick(now time.Time)
- type URLConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SDKDir ¶
SDKDir holds the AWS SDKs native runtimes lack (see `pogi lambda-sdks`): node_modules for Node.js, python/ for boto3. Function code is unpacked below it, so Node's module lookup finds the SDK without NODE_PATH.
func WriteHTTPResult ¶
func WriteHTTPResult(w http.ResponseWriter, result []byte)
WriteHTTPResult maps a function result to an HTTP response (payload 2.0 rules): an object with statusCode is a full response, anything else is a JSON body.
Types ¶
type Alias ¶
type Alias struct {
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description,omitempty"`
Weights map[string]float64 `json:"weights,omitempty"`
RevisionID string `json:"revisionId"`
}
Alias points at a version, optionally splitting traffic.
type Config ¶
type Config struct {
Version string `json:"version"`
Runtime string `json:"runtime,omitempty"`
Handler string `json:"handler,omitempty"`
Role string `json:"role"`
Description string `json:"description,omitempty"`
Timeout int `json:"timeout"`
MemorySize int `json:"memorySize"`
Env map[string]string `json:"env,omitempty"`
PackageType string `json:"packageType"`
ImageURI string `json:"imageUri,omitempty"`
ImageConfig *ImageConfig `json:"imageConfig,omitempty"`
Code []byte `json:"code,omitempty"`
CodeDir string `json:"codeDir,omitempty"` // hot reload
CodeSha256 string `json:"codeSha256"`
CodeSize int64 `json:"codeSize"`
Layers []string `json:"layers,omitempty"`
Architectures []string `json:"architectures,omitempty"`
DeadLetterArn string `json:"deadLetterArn,omitempty"`
TracingMode string `json:"tracingMode,omitempty"`
Ephemeral int `json:"ephemeral,omitempty"`
Vpc json.RawMessage `json:"vpc,omitempty"`
Modified time.Time `json:"modified"`
RevisionID string `json:"revisionId"`
}
Config is one immutable (or $LATEST) function configuration.
type Function ¶
type Function struct {
Name string `json:"name"`
Account string `json:"account"`
Region string `json:"region"`
Latest *Config `json:"latest"`
Versions map[string]*Config `json:"versions,omitempty"`
NextVersion int `json:"nextVersion"`
Aliases map[string]*Alias `json:"aliases,omitempty"`
Policy []map[string]any `json:"policy,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
Reserved *int `json:"reserved,omitempty"`
Provisioned map[string]*Provisioned `json:"provisioned,omitempty"` // version or alias → provisioned concurrency
URL *URLConfig `json:"url,omitempty"`
EventInvoke map[string]any `json:"eventInvoke,omitempty"`
}
Function is a function with its $LATEST config, versions and aliases.
type ImageConfig ¶
type ImageConfig struct {
EntryPoint []string `json:",omitempty"`
Command []string `json:",omitempty"`
WorkingDirectory string `json:",omitempty"`
}
ImageConfig overrides a container image's entrypoint, command and working directory.
type InvokeResult ¶
InvokeResult is what the console shows after a test invoke.
type Layer ¶
type Layer struct {
Name string `json:"name"`
Account string `json:"account"`
Region string `json:"region"`
Versions map[int]*LayerVersion `json:"versions"`
Next int `json:"next"`
}
Layer holds the versions of one layer.
type LayerVersion ¶
type LayerVersion struct {
Version int `json:"version"`
Zip []byte `json:"zip"`
Sha string `json:"sha"`
Description string `json:"description,omitempty"`
License string `json:"license,omitempty"`
Runtimes []string `json:"runtimes,omitempty"`
Archs []string `json:"archs,omitempty"`
Created time.Time `json:"created"`
}
LayerVersion is one published layer version.
type Mapping ¶
type Mapping struct {
UUID string `json:"uuid"`
Account string `json:"account"`
Region string `json:"region"`
FunctionArn string `json:"functionArn"`
SourceArn string `json:"sourceArn"`
BatchSize int `json:"batchSize"`
Window int `json:"window"`
StartingPosition string `json:"startingPosition,omitempty"`
StartingTimestamp float64 `json:"startingTimestamp,omitempty"`
Enabled bool `json:"enabled"`
Filters []string `json:"filters,omitempty"`
ResponseTypes []string `json:"responseTypes,omitempty"`
MaxRetry int `json:"maxRetry"`
Bisect bool `json:"bisect,omitempty"`
MaxConcurrency int `json:"maxConcurrency,omitempty"` // ScalingConfig.MaximumConcurrency, kept but not used to limit polling
OnFailure string `json:"onFailure,omitempty"`
Topics []string `json:"topics,omitempty"` // self-managed Kafka
Endpoints []string `json:"endpoints,omitempty"` // its KAFKA_BOOTSTRAP_SERVERS
Access []accessConfig `json:"access,omitempty"` // its SourceAccessConfigurations
ConsumerGroup string `json:"consumerGroup,omitempty"` // its consumer group id
Modified time.Time `json:"modified"`
LastResult string `json:"lastResult"`
Tags map[string]string `json:"tags,omitempty"`
}
Mapping is an event source mapping (SQS, DynamoDB Streams, Kinesis or self-managed Kafka → function).
type Provisioned ¶
type Provisioned struct {
Requested int `json:"requested"`
Status string `json:"status"` // IN_PROGRESS, READY or FAILED
Reason string `json:"reason,omitempty"`
Modified time.Time `json:"modified"`
}
Provisioned is the provisioned concurrency of a version or alias.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the Lambda emulator.
func (*Service) BodyLimit ¶
BodyLimit raises the upload limit for function code: CreateFunction, UpdateFunctionCode and PublishLayerVersion carry a zip of up to 50 MB as base64 in JSON.
func (*Service) Inspect ¶
Inspect returns a function's configuration, versions, aliases, policy and recent logs.
func (*Service) Invoke ¶
func (s *Service) Invoke(account, region, name string, payload []byte) (InvokeResult, error)
Invoke runs a function synchronously from the console.
func (*Service) Links ¶
Links are the event source mappings, from the stream or queue to the function.
func (*Service) RecentLogs ¶
RecentLogs returns the last log lines of a function.
func (*Service) TaggedResources ¶
TaggedResources lists functions (ARN → tags) for the tagging API and Resource Explorer.