Documentation ¶
Overview ¶
Package lambda implements a plugin to run OPA as an AWS Lambda Extension.
Index ¶
- Constants
- type Client
- func (e *Client) ExitError(ctx context.Context, errorType string) (*StatusResponse, error)
- func (e *Client) InitError(ctx context.Context, errorType string) (*StatusResponse, error)
- func (e *Client) NextEvent(ctx context.Context) (*NextEventResponse, error)
- func (e *Client) Register(ctx context.Context, filename string) (*RegisterResponse, error)
- type Config
- type EventType
- type NextEventResponse
- type Plugin
- type PluginFactory
- type RegisterResponse
- type StatusResponse
- type Tracing
Constants ¶
const (
// Name is the name of the plugin
Name = "lambda_extension"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a simple client for the Lambda Extensions API
func (*Client) ExitError ¶
ExitError reports an error to the platform before exiting. Call it when you encounter an unexpected failure
func (*Client) InitError ¶
InitError reports an initialization error to the platform. Call it when you registered but failed to initialize
type Config ¶
type Config struct { // The minimum time in seconds that must elapse before plugins will be triggered. Right now, // all plugins are triggered at once, and they all must use the same minimum threshold. MinimumTriggerThreshold *int `json:"minimum_trigger_threshold,omitempty"` // The maximum time in seconds that ALL plugins have to run. Once the timeout elapses, all plugin // runs will be cancelled and the lambda_extension plugin will move on to the next event. TriggerTimeout *int `json:"trigger_timeout,omitempty"` // The order, from first to last, that plugins will be started during intialization. PluginStartPriority *[]string `json:"plugin_start_priority,omitempty"` // the order, from first to last, that plugins will be stopped during shutdown. PluginStopPriority *[]string `json:"plugin_stop_priority,omitempty"` }
Config represents the plugin configuration.
type EventType ¶
type EventType string
EventType represents the type of events recieved from /event/next
type NextEventResponse ¶
type NextEventResponse struct { EventType EventType `json:"eventType"` DeadlineMs int64 `json:"deadlineMs"` RequestID string `json:"requestId"` InvokedFunctionArn string `json:"invokedFunctionArn"` Tracing Tracing `json:"tracing"` }
NextEventResponse is the response for /event/next
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin implements a Lambda Extension client and controls OPA in a manner that is compatible with the Lambda Extension lifecycle. Instead of plugins being triggered periodically after a configured delay, they are triggered by this plugin after a minimum threshold of time has passed. When the minimum threshold has elapsed, the plugins will be triggered as soon as the Lambda Service indicates the next event is ready to process. This happens in parallel with the Lambda function running, so there is no guarantee that triggers will complete before the function completes its processing. The function is capable of responding to the client while the lambda extension is still triggering plugins. However, this plugin won't request the next event from the Lambda service until all triggers are complete (or timeout). This has ramifications for bundle loading and log shipping. When a bundle is changed, there will always be at least one lambda event that does not process with the new bundle. Likewise, it is possible for some logs to not ship until the Lambda shuts down from idleness (i.e. if X requests are processed before the minimum threshold of time has elapsed, then they will sit in the buffer until the next request, or when this plugin processes the lambda shutdown event).
func (*Plugin) Reconfigure ¶
Reconfigure does nothing for this plugin.
type PluginFactory ¶
type PluginFactory struct{}
PluginFactory is used by the plugin manager to create plugins and their configuration
type RegisterResponse ¶
type RegisterResponse struct { FunctionName string `json:"functionName"` FunctionVersion string `json:"functionVersion"` Handler string `json:"handler"` }
RegisterResponse is the body of the response for /register
type StatusResponse ¶
type StatusResponse struct {
Status string `json:"status"`
}
StatusResponse is the body of the response for /init/error and /exit/error