Documentation
¶
Index ¶
- type FunctionChecker
- type ImageFunctionSource
- type ImageSpec
- type InvocationRecord
- type LogSink
- type Service
- func (s *Service) ClearInvocations()
- func (s *Service) Containers() map[string]string
- func (s *Service) ContainersHandler(w http.ResponseWriter, r *http.Request)
- func (s *Service) DirectInvoke(functionName string, payload []byte) ([]byte, error)
- func (s *Service) EnableContainers(images ImageFunctionSource, dataDir string, logs LogSink)
- func (s *Service) Invocations() []*InvocationRecord
- func (s *Service) InvocationsHandler(w http.ResponseWriter, r *http.Request)
- func (s *Service) Invoke(w http.ResponseWriter, r *http.Request, name string)
- func (s *Service) InvokeAsync(w http.ResponseWriter, r *http.Request, name string)
- func (s *Service) InvokeWithResponseStream(w http.ResponseWriter, r *http.Request, name string)
- func (s *Service) LiveEndpoint(name string) string
- func (s *Service) LiveEndpoints() map[string]string
- func (s *Service) RegisterHandler(w http.ResponseWriter, r *http.Request)
- func (s *Service) ReleaseFunction(name string)
- func (s *Service) Reset()
- func (s *Service) SetResponse(name string, payload json.RawMessage)
- func (s *Service) Shutdown()
- func (s *Service) StopContainers()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FunctionChecker ¶
FunctionChecker lets the invocation service verify a function exists without creating an import cycle back to function_crud.
type ImageFunctionSource ¶ added in v0.4.26
ImageFunctionSource supplies container-image details for a function. The function store implements it; when it is absent or reports false, invocation falls back to the mock/proxy path.
type ImageSpec ¶ added in v0.4.26
type ImageSpec struct {
ImageURI string
Arch string // "x86_64" | "arm64"
MemoryMB int
TimeoutSec int
EphemeralMB int
Env map[string]string
EntryPoint []string // ImageConfig overrides, empty to use the image's own
Command []string
WorkingDir string
}
ImageSpec is everything needed to start a container-image function.
type InvocationRecord ¶
type InvocationRecord struct {
FunctionName string `json:"FunctionName"`
Qualifier string `json:"Qualifier,omitempty"`
InvocationType string `json:"InvocationType"`
Payload json.RawMessage `json:"Payload,omitempty"`
InvokedAt time.Time `json:"InvokedAt"`
}
InvocationRecord captures a single Lambda invocation for test inspection. Exposed via the /_nimbus/lambda/invocations endpoint.
type LogSink ¶ added in v0.4.26
LogSink receives a function container's output. CloudWatch Logs implements it; when absent, container output is simply not forwarded.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service handles Lambda invocation operations and stores mock state.
func New ¶
func New(checker FunctionChecker) *Service
func (*Service) ClearInvocations ¶
func (s *Service) ClearInvocations()
ClearInvocations removes all recorded invocations.
func (*Service) Containers ¶ added in v0.4.26
Containers reports the container ID backing each running image function.
func (*Service) ContainersHandler ¶ added in v0.4.26
func (s *Service) ContainersHandler(w http.ResponseWriter, r *http.Request)
ContainersHandler serves GET /_nimbus/lambda/containers for inspection and DELETE to tear every running container down.
func (*Service) DirectInvoke ¶ added in v0.1.10
DirectInvoke invokes a function synchronously without going through HTTP. If a live endpoint is registered for the function, it proxies there; otherwise it returns the configured mock response.
func (*Service) EnableContainers ¶ added in v0.4.26
func (s *Service) EnableContainers(images ImageFunctionSource, dataDir string, logs LogSink)
EnableContainers turns on real execution for container-image functions. Without it — or without a reachable Docker daemon — image functions keep using the mock/proxy path.
func (*Service) Invocations ¶
func (s *Service) Invocations() []*InvocationRecord
Invocations returns a snapshot of all recorded invocations.
func (*Service) InvocationsHandler ¶ added in v0.4.13
func (s *Service) InvocationsHandler(w http.ResponseWriter, r *http.Request)
InvocationsHandler serves GET /_nimbus/lambda/invocations and DELETE /_nimbus/lambda/invocations for test inspection.
func (*Service) InvokeAsync ¶
POST /2015-03-31/functions/{FunctionName}/invoke-async/
Deprecated by AWS — preserved here for SDK backwards-compatibility. Always returns 202; the payload is recorded but no response is sent back.
func (*Service) InvokeWithResponseStream ¶
POST /2015-03-31/functions/{FunctionName}/response-streaming-invocations
The real API streams chunks back using chunked transfer encoding. This mock returns the configured response as a single write — sufficient for SDKs that reassemble the stream before returning it to callers.
func (*Service) LiveEndpoint ¶ added in v0.4.13
LiveEndpoint returns the registered live endpoint for the given function, if any.
func (*Service) LiveEndpoints ¶ added in v0.4.13
LiveEndpoints returns a snapshot of all registered live endpoints.
func (*Service) RegisterHandler ¶ added in v0.4.13
func (s *Service) RegisterHandler(w http.ResponseWriter, r *http.Request)
RegisterHandler serves POST /_nimbus/lambda/register and DELETE /_nimbus/lambda/register/{function_name} for forge live dev.
func (*Service) ReleaseFunction ¶ added in v0.4.26
ReleaseFunction tears down a function's container, if it has one. Called when the function is deleted.
func (*Service) Reset ¶ added in v0.4.13
func (s *Service) Reset()
Reset clears all mock responses, recorded invocations, and live endpoints, and tears down any running function containers.
func (*Service) SetResponse ¶
func (s *Service) SetResponse(name string, payload json.RawMessage)
SetResponse configures the payload the mock returns when the named function is invoked.
func (*Service) Shutdown ¶ added in v0.4.26
func (s *Service) Shutdown()
Shutdown tears down every container and stops the idle reaper. Called on process exit so containers do not outlive the process that started them.
func (*Service) StopContainers ¶ added in v0.4.26
func (s *Service) StopContainers()
StopContainers tears down every running function container, leaving the service able to start more.