interop

package
v0.0.0-...-6be47e1 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxPayloadSize = 6*1024*1024 + 100 // 6 MiB + 100 bytes

	ResponseBandwidthRate      = 2 * 1024 * 1024 // default average rate of 2 MiB/s
	ResponseBandwidthBurstSize = 6 * 1024 * 1024 // default burst size of 6 MiB

	MinResponseBandwidthRate = 32 * 1024        // 32 KiB/s
	MaxResponseBandwidthRate = 64 * 1024 * 1024 // 64 MiB/s

	MinResponseBandwidthBurstSize = 32 * 1024        // 32 KiB
	MaxResponseBandwidthBurstSize = 64 * 1024 * 1024 // 64 MiB
)

MaxPayloadSize max event body size declared as LAMBDA_EVENT_BODY_SIZE

View Source
const (
	HTTPConnKey key = iota
)
View Source
const ResponseModeBuffered = "Buffered"
View Source
const ResponseModeStreaming = "Streaming"

Variables

View Source
var ErrCannotParseCredentialsExpiry = errors.New("errCannotParseCredentialsExpiry")
View Source
var ErrCannotParseRestoreHookTimeoutMs = errors.New("errCannotParseRestoreHookTimeoutMs")
View Source
var ErrInvalidFunctionResponseMode = fmt.Errorf("ErrInvalidFunctionResponseMode")

ErrInvalidFunctionResponseMode is returned when the value sent by runtime during Invoke2 is not a constant of type interop.FunctionResponseMode

View Source
var ErrInvalidFunctionVersion = fmt.Errorf("ErrInvalidFunctionVersion")

ErrInvalidFunctionVersion is returned when functionVersion provided in Invoke2 does not match one provided in Token

View Source
var ErrInvalidInvokeID = fmt.Errorf("ErrInvalidInvokeID")

ErrInvalidInvokeID is returned when invokeID provided in Invoke2 does not match one provided in Token

View Source
var ErrInvalidInvokeResponseMode = fmt.Errorf("ErrInvalidInvokeResponseMode")

ErrInvalidInvokeResponseMode is returned when optional InvokeResponseMode header provided in Invoke2 is not a constant of type interop.InvokeResponseMode

View Source
var ErrInvalidMaxPayloadSize = fmt.Errorf("ErrInvalidMaxPayloadSize")

ErrInvalidMaxPayloadSize is returned when optional MaxPayloadSize header provided in Invoke2 is invalid

View Source
var ErrInvalidReservationToken = fmt.Errorf("ErrInvalidReservationToken")

ErrInvalidReservationToken is returned when reservationToken provided in Invoke2 does not match one provided in Token

View Source
var ErrInvalidResponseBandwidthBurstSize = fmt.Errorf("ErrInvalidResponseBandwidthBurstSize")

ErrInvalidResponseBandwidthBurstSize is returned when optional ResponseBandwidthBurstSize header provided in Invoke2 is invalid

View Source
var ErrInvalidResponseBandwidthRate = fmt.Errorf("ErrInvalidResponseBandwidthRate")

ErrInvalidResponseBandwidthRate is returned when optional ResponseBandwidthRate header provided in Invoke2 is invalid

View Source
var ErrMalformedCustomerHeaders = fmt.Errorf("ErrMalformedCustomerHeaders")

ErrMalformedCustomerHeaders is returned when customer headers format is invalid

View Source
var ErrMissingRestoreCredentials = errors.New("errMissingRestoreCredentials")
View Source
var ErrReservationExpired = fmt.Errorf("ErrReservationExpired")

ErrReservationExpired is returned when invoke arrived after InvackDeadline

View Source
var ErrResponseSent = fmt.Errorf("ErrResponseSent")

ErrResponseSent is returned when response with given invokeID was already sent.

View Source
var ErrRestoreHookTimeout = errors.New("Runtime.RestoreHookUserTimeout")

ErrRestoreHookTimeout is returned as a response to `RESTORE` message when function's restore hook takes more time to execute thatn the timeout value.

View Source
var ErrRestoreUpdateCredentials = errors.New("errRestoreUpdateCredentials")

ErrRestoreUpdateCredentials is returned as a response to `RESTORE` message if RAPID cannot update the credentials served by credentials API during the RESTORE phase.

Functions

func GetConn

func GetConn(r *http.Request) net.Conn

func IsResponseStreamingMetrics

func IsResponseStreamingMetrics(metrics *InvokeResponseMetrics) bool

Types

type Bootstrap

type Bootstrap interface {
	Cmd() ([]string, error)                   // returns the args of bootstrap, where args[0] is the path to executable
	Env(e *env.Environment) map[string]string // returns the environment variables to be passed to the bootstrapped process
	Cwd() (string, error)                     // returns the working directory of the bootstrap process
	ExtraFiles() []*os.File                   // returns the extra file descriptors apart from 1 & 2 to be passed to runtime
	CachedFatalError(err error) (fatalerror.ErrorType, string, bool)
}

type CancellableRequest

type CancellableRequest struct {
	Request *http.Request
}

func (*CancellableRequest) Cancel

func (c *CancellableRequest) Cancel() error

type Done

type Done struct {
	WaitForExit bool
	ErrorType   fatalerror.ErrorType
	Meta        DoneMetadata
}

func DoneFromInvokeSuccess

func DoneFromInvokeSuccess(successMsg InvokeSuccess) *Done

type DoneFail

type DoneFail struct {
	ErrorType fatalerror.ErrorType
	Meta      DoneMetadata
}

func DoneFailFromInitFailure

func DoneFailFromInitFailure(initFailure *InitFailure) *DoneFail

func DoneFailFromInvokeFailure

func DoneFailFromInvokeFailure(failureMsg *InvokeFailure) *DoneFail

type DoneMetadata

type DoneMetadata struct {
	NumActiveExtensions int
	ExtensionsResetMs   int64
	ExtensionNames      string
	RuntimeRelease      string
	// Metrics for response status of LogsAPI `/subscribe` calls
	LogsAPIMetrics               TelemetrySubscriptionMetrics
	InvokeRequestReadTimeNs      int64
	InvokeRequestSizeBytes       int64
	InvokeCompletionTimeNs       int64
	InvokeReceivedTime           int64
	RuntimeReadyTime             int64
	RuntimeResponseLatencyMs     float64
	RuntimeTimeThrottledMs       int64
	RuntimeProducedBytes         int64
	RuntimeOutboundThroughputBps int64
	MetricsDimensions            DoneMetadataMetricsDimensions
}

type DoneMetadataMetricsDimensions

type DoneMetadataMetricsDimensions struct {
	InvokeResponseMode InvokeResponseMode
}

func (DoneMetadataMetricsDimensions) String

func (dimensions DoneMetadataMetricsDimensions) String() string

type DynamicDomainConfig

type DynamicDomainConfig struct {
	// extra hooks to execute at domain start. Currently used for filesystem and network hooks.
	// It can be empty.
	AdditionalStartHooks []model.Hook
	Mounts               []model.Mount
}

Captures configuration of the operator and runtime domain that are only known after INIT is received

type EndData

type EndData struct {
	RequestID RequestID `json:"requestId"`
}

func (*EndData) String

func (d *EndData) String() string

type ErrInternalPlatformError

type ErrInternalPlatformError struct{}

ErrInternalPlatformError is returned when internal platform error occurred

func (*ErrInternalPlatformError) Error

func (s *ErrInternalPlatformError) Error() string

type ErrRestoreHookUserError

type ErrRestoreHookUserError struct {
	UserError FunctionError
}

ErrRestoreHookUserError is returned as a response to `RESTORE` message when function's restore hook faces with an error on throws an exception. UserError contains the error type that the runtime encountered.

func (ErrRestoreHookUserError) Error

func (err ErrRestoreHookUserError) Error() string

type ErrTruncatedResponse

type ErrTruncatedResponse struct{}

ErrTruncatedResponse is returned when response is truncated

func (*ErrTruncatedResponse) Error

func (s *ErrTruncatedResponse) Error() string

type ErrorInvokeResponse

type ErrorInvokeResponse struct {
	Headers       InvokeResponseHeaders
	Payload       []byte
	FunctionError FunctionError
}

ErrorInvokeResponse represents a buffered response received via Runtime API for error responses. When body (Payload) is not provided, e.g. not retrievable, error type and error message headers will be used by the platform to construct a response json, e.g:

default error response produced by the Slicer: '{"errorMessage":"Unknown application error occurred"}',

when error type is provided, error response becomes: '{"errorMessage":"Unknown application error occurred","errorType":"ErrorType"}'

func GetErrorResponseWithFormattedErrorMessage

func GetErrorResponseWithFormattedErrorMessage(errorType fatalerror.ErrorType, err error, invokeRequestID string) *ErrorInvokeResponse

type ErrorResponseTooLarge

type ErrorResponseTooLarge struct {
	MaxResponseSize int
	ResponseSize    int
}

ErrorResponseTooLarge is returned when response Payload exceeds shared memory buffer size

func (*ErrorResponseTooLarge) AsErrorResponse

func (s *ErrorResponseTooLarge) AsErrorResponse() *ErrorInvokeResponse

AsErrorResponse generates ErrorInvokeResponse from ErrorResponseTooLarge

func (*ErrorResponseTooLarge) Error

func (s *ErrorResponseTooLarge) Error() string

ErrorResponseTooLarge is returned when response provided by Runtime does not fit into shared memory buffer

type ErrorResponseTooLargeDI

type ErrorResponseTooLargeDI struct {
	ErrorResponseTooLarge
}

ErrorResponseTooLargeDI is used to reproduce ErrorResponseTooLarge behavior for Direct Invoke mode

type EventsAPI

type EventsAPI interface {
	SetCurrentRequestID(RequestID)
	SendInitStart(InitStartData) error
	SendInitRuntimeDone(InitRuntimeDoneData) error
	SendInitReport(InitReportData) error
	SendRestoreRuntimeDone(RestoreRuntimeDoneData) error
	SendInvokeStart(InvokeStartData) error
	SendInvokeRuntimeDone(InvokeRuntimeDoneData) error
	SendExtensionInit(ExtensionInitData) error
	SendReportSpan(Span) error
	SendReport(ReportData) error
	SendEnd(EndData) error
	SendFault(FaultData) error
	SendImageErrorLog(ImageErrorLogData)

	FetchTailLogs(string) (string, error)
	GetRuntimeDoneSpans(
		runtimeStartedTime int64,
		invokeResponseMetrics *InvokeResponseMetrics,
		runtimeOverheadStartedTime int64,
		runtimeReadyTime int64,
	) []Span
}

type ExtensionInitData

type ExtensionInitData struct {
	AgentName     string   `json:"name"`
	State         string   `json:"state"`
	Subscriptions []string `json:"events"`
	ErrorType     string   `json:"errorType,omitempty"`
}

func (*ExtensionInitData) String

func (d *ExtensionInitData) String() string

type FaultData

type FaultData struct {
	RequestID    RequestID
	ErrorMessage error
	ErrorType    fatalerror.ErrorType
}

func (*FaultData) String

func (d *FaultData) String() string

type FunctionError

type FunctionError struct {
	// Type of error is derived from the Lambda-Runtime-Function-Error-Type set by the Runtime
	// This is customer data, so RAPID scrubs this error type to contain only allowlisted values
	Type fatalerror.ErrorType `json:"errorType,omitempty"`
	// ErrorMessage is generated by RAPID and can never be specified by runtime
	Message string `json:"errorMessage,omitempty"`
}

FunctionError represents information about function errors or 'user errors' These are not platform errors and hence are returned as 200 by Lambda In the absence of a response payload, the Function Error is serialized and sent

type FunctionResponseMode

type FunctionResponseMode string

FunctionResponseMode is passed by Runtime to tell whether the response should be streamed or not.

const FunctionResponseModeBuffered FunctionResponseMode = ResponseModeBuffered
const FunctionResponseModeStreaming FunctionResponseMode = ResponseModeStreaming

func ConvertToFunctionResponseMode

func ConvertToFunctionResponseMode(value string) (FunctionResponseMode, error)

TODO: move to directinvoke.go as we're trying to deprecate interop.* package ConvertToFunctionResponseMode converts the given string to a FunctionResponseMode It is case insensitive and if there is no match, an error is thrown.

type ImageErrorLogData

type ImageErrorLogData string

type Init

type Init struct {
	InvokeID          string
	Handler           string
	AccountID         string
	AwsKey            string
	AwsSecret         string
	AwsSession        string
	CredentialsExpiry time.Time
	SuppressInit      bool
	InvokeTimeoutMs   int64  // timeout duration of whole invoke
	InitTimeoutMs     int64  // timeout duration for init only
	XRayDaemonAddress string // only in standalone
	FunctionName      string // only in standalone
	FunctionVersion   string // only in standalone
	// In standalone mode, these env vars come from test/init but from environment otherwise.
	CustomerEnvironmentVariables map[string]string
	SandboxType                  SandboxType
	LogStreamName                string
	InstanceMaxMemory            uint64
	OperatorDomainExtraConfig    DynamicDomainConfig
	RuntimeDomainExtraConfig     DynamicDomainConfig
	RuntimeInfo                  RuntimeInfo
	Bootstrap                    Bootstrap
	EnvironmentVariables         *env.Environment // contains env vars for agents and runtime procs
}

Init represents an init message In Rapid Shim, this is a START GirD message In Rapid Daemon, this is an INIT GirP message

type InitContext

type InitContext interface {
	Wait() (InitSuccess, *InitFailure)
	Reserve() InvokeContext
}

InitContext represents the lifecycle of a sandbox initialization

type InitFailure

type InitFailure struct {
	ResetReceived       bool // indicates if failure happened due to a reset received
	RequestReset        bool // Indicates whether reset should be requested on init failure
	ErrorType           fatalerror.ErrorType
	ErrorMessage        error
	NumActiveExtensions int
	RuntimeRelease      string // value of the User Agent HTTP header provided by runtime
	LogsAPIMetrics      TelemetrySubscriptionMetrics
	Ack                 chan struct{} // used by the sending goroutine to wait until ipc message has been sent
}

InitFailure indicates that runtime/extensions initialization failed due to process exit or /error calls In Rapid Shim, this translates to either a DONE or a DONEFAIL GirD message to Slicer (depending on extensions mode) However, even on failure, the next invoke is expected to work with a suppressed init - i.e. we init again as aprt of the invoke

type InitPhase

type InitPhase string

type InitReportData

type InitReportData struct {
	InitializationType InitType          `json:"initializationType"`
	Metrics            InitReportMetrics `json:"metrics"`
	Phase              InitPhase         `json:"phase"`
	Tracing            *TracingCtx       `json:"tracing,omitempty"`
}

func (*InitReportData) String

func (d *InitReportData) String() string

type InitReportMetrics

type InitReportMetrics struct {
	DurationMs float64 `json:"durationMs"`
}

type InitRuntimeDoneData

type InitRuntimeDoneData struct {
	InitializationType InitType    `json:"initializationType"`
	Status             string      `json:"status"`
	Phase              InitPhase   `json:"phase"`
	ErrorType          *string     `json:"errorType,omitempty"`
	Tracing            *TracingCtx `json:"tracing,omitempty"`
}

func (*InitRuntimeDoneData) String

func (d *InitRuntimeDoneData) String() string

type InitStartData

type InitStartData struct {
	InitializationType InitType    `json:"initializationType"`
	RuntimeVersion     string      `json:"runtimeVersion"`
	RuntimeVersionArn  string      `json:"runtimeVersionArn"`
	FunctionName       string      `json:"functionName"`
	FunctionArn        string      `json:"functionArn"`
	FunctionVersion    string      `json:"functionVersion"`
	InstanceID         string      `json:"instanceId"`
	InstanceMaxMemory  uint64      `json:"instanceMaxMemory"`
	Phase              InitPhase   `json:"phase"`
	Tracing            *TracingCtx `json:"tracing,omitempty"`
}

func (*InitStartData) String

func (d *InitStartData) String() string

type InitSuccess

type InitSuccess struct {
	NumActiveExtensions int    // indicates number of active extensions
	ExtensionNames      string // file names of extensions in /opt/extensions
	RuntimeRelease      string
	LogsAPIMetrics      TelemetrySubscriptionMetrics // used if telemetry API enabled
	Ack                 chan struct{}                // used by the sending goroutine to wait until ipc message has been sent
}

InitSuccess indicates that runtime/extensions initialization completed successfully In Rapid Shim, this translates to a DONE GirD message to Slicer In Rapid Daemon, this is followed by a DONEDONE GirP message to MM

type InitType

type InitType string

InitializationType describes possible types of INIT phase

type InternalStateGetter

type InternalStateGetter func() statejson.InternalStateDescription

type Invoke

type Invoke struct {
	// Tracing header.
	// https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-tracingheader
	TraceID                  string
	LambdaSegmentID          string
	ID                       string
	InvokedFunctionArn       string
	CognitoIdentityID        string
	CognitoIdentityPoolID    string
	DeadlineNs               string
	ClientContext            string
	ContentType              string
	Payload                  io.Reader
	NeedDebugLogs            bool
	ReservationToken         string
	VersionID                string
	InvokeReceivedTime       int64
	InvokeResponseMetrics    *InvokeResponseMetrics
	InvokeResponseMode       InvokeResponseMode
	RestoreDurationNs        int64 // equals 0 for non-snapstart functions
	RestoreStartTimeMonotime int64 // equals 0 for non-snapstart functions
}

Invoke is an invocation request received from the slicer.

type InvokeContext

type InvokeContext interface {
	SendRequest(i *Invoke, r InvokeResponseSender)
	Wait() (InvokeSuccess, *InvokeFailure)
}

InvokeContext represents the lifecycle of a sandbox reservation

type InvokeErrorTraceData

type InvokeErrorTraceData struct {
	// Attached to invoke segment
	ErrorCause json.RawMessage `json:"ErrorCause,omitempty"`
}

InvokeErrorTraceData is used by the tracer to mark segments as being invocation error

type InvokeFailure

type InvokeFailure struct {
	ResetReceived        bool // indicates if failure happened due to a reset received
	RequestReset         bool // indicates if reset must be requested after the failure
	ErrorType            fatalerror.ErrorType
	ErrorMessage         error
	RuntimeRelease       string // value of the User Agent HTTP header provided by runtime
	NumActiveExtensions  int
	InvokeReceivedTime   int64
	LogsAPIMetrics       TelemetrySubscriptionMetrics
	ResponseMetrics      ResponseMetrics
	InvokeMetrics        InvokeMetrics
	ExtensionNames       string
	DefaultErrorResponse *ErrorInvokeResponse // error resp constructed by platform during fn errors
	InvokeResponseMode   InvokeResponseMode
}

InvokeFailure is the failure response to invoke phase end

type InvokeMetrics

type InvokeMetrics struct {
	InvokeRequestReadTimeNs int64
	InvokeRequestSizeBytes  int64
	RuntimeReadyTime        int64
}

InvokeMetrics groups metrics related to the invoke phase

type InvokeResponseHeaders

type InvokeResponseHeaders struct {
	ContentType          string
	FunctionResponseMode string
}

InvokeResponseHeaders contains the headers received via Runtime API /invocation/response

type InvokeResponseMetrics

type InvokeResponseMetrics struct {
	// FIXME: this assumes a value in nanoseconds, let's rename it
	// to StartReadingResponseMonoTimeNs
	StartReadingResponseMonoTimeMs int64
	// Same as the one above
	FinishReadingResponseMonoTimeMs int64
	TimeShapedNs                    int64
	ProducedBytes                   int64
	OutboundThroughputBps           int64 // in bytes per second
	FunctionResponseMode            FunctionResponseMode
	RuntimeCalledResponse           bool
}

InvokeResponseMetrics are produced while sending streaming invoke response to WP

type InvokeResponseMode

type InvokeResponseMode string
const InvokeResponseModeBuffered InvokeResponseMode = ResponseModeBuffered
const InvokeResponseModeStreaming InvokeResponseMode = ResponseModeStreaming

type InvokeResponseSender

type InvokeResponseSender interface {
	// SendResponse sends invocation response received from Runtime to platform
	// This is response may be streamed based on function and invoke response mode
	SendResponse(invokeID string, response *StreamableInvokeResponse) error
	// SendErrorResponse sends error response in the case of function errors, which are always buffered
	SendErrorResponse(invokeID string, response *ErrorInvokeResponse) error
}

type InvokeRuntimeDoneData

type InvokeRuntimeDoneData struct {
	RequestID       RequestID                 `json:"requestId"`
	Status          string                    `json:"status"`
	Metrics         *RuntimeDoneInvokeMetrics `json:"metrics,omitempty"`
	Tracing         *TracingCtx               `json:"tracing,omitempty"`
	Spans           []Span                    `json:"spans,omitempty"`
	ErrorType       *string                   `json:"errorType,omitempty"`
	InternalMetrics *InvokeResponseMetrics    `json:"-"`
}

func (*InvokeRuntimeDoneData) String

func (d *InvokeRuntimeDoneData) String() string

type InvokeStartData

type InvokeStartData struct {
	RequestID string      `json:"requestId"`
	Version   string      `json:"version,omitempty"`
	Tracing   *TracingCtx `json:"tracing,omitempty"`
}

func (*InvokeStartData) String

func (d *InvokeStartData) String() string

type InvokeSuccess

type InvokeSuccess struct {
	RuntimeRelease         string // value of the User Agent HTTP header provided by runtime
	NumActiveExtensions    int
	ExtensionNames         string
	InvokeCompletionTimeNs int64
	InvokeReceivedTime     int64
	LogsAPIMetrics         TelemetrySubscriptionMetrics
	ResponseMetrics        ResponseMetrics
	InvokeMetrics          InvokeMetrics
	InvokeResponseMode     InvokeResponseMode
}

InvokeSuccess is the success response to invoke phase end

type LifecyclePhase

type LifecyclePhase int

LifecyclePhase represents enum for possible Sandbox lifecycle phases, like init, invoke, etc.

const (
	LifecyclePhaseInit LifecyclePhase = iota + 1
	LifecyclePhaseInvoke
)

type Message

type Message interface{}

Message is a generic interop message.

type RapidContext

type RapidContext interface {
	HandleInit(i *Init, success chan<- InitSuccess, failure chan<- InitFailure)
	HandleInvoke(i *Invoke, sbMetadata SandboxInfoFromInit, requestBuf *bytes.Buffer, responseSender InvokeResponseSender) (InvokeSuccess, *InvokeFailure)
	HandleReset(reset *Reset) (ResetSuccess, *ResetFailure)
	HandleShutdown(shutdown *Shutdown) ShutdownSuccess
	HandleRestore(restore *Restore) (RestoreResult, error)
	Clear()

	SetRuntimeStartedTime(runtimeStartedTime int64)
	SetInvokeResponseMetrics(metrics *InvokeResponseMetrics)

	SetEventsAPI(eventsAPI EventsAPI)
}

RapidContext expose methods for functionality of the Rapid Core library

type ReportData

type ReportData struct {
	RequestID RequestID     `json:"requestId"`
	Status    string        `json:"status"`
	Metrics   ReportMetrics `json:"metrics"`
	Tracing   *TracingCtx   `json:"tracing,omitempty"`
	Spans     []Span        `json:"spans,omitempty"`
	ErrorType *string       `json:"errorType,omitempty"`
}

func (*ReportData) String

func (d *ReportData) String() string

type ReportMetrics

type ReportMetrics struct {
	DurationMs       float64 `json:"durationMs"`
	BilledDurationMs float64 `json:"billedDurationMs"`
	MemorySizeMB     uint64  `json:"memorySizeMB"`
	MaxMemoryUsedMB  uint64  `json:"maxMemoryUsedMB"`
	InitDurationMs   float64 `json:"initDurationMs,omitempty"`
}

type RequestID

type RequestID string

type Reset

type Reset struct {
	Reason                string
	DeadlineNs            int64
	InvokeResponseMetrics *InvokeResponseMetrics
	TraceID               string
	LambdaSegmentID       string
	InvokeResponseMode    InvokeResponseMode
}

Reset message is sent to rapid to initiate reset sequence

type ResetFailure

type ResetFailure struct {
	ExtensionsResetMs  int64
	ErrorType          fatalerror.ErrorType
	ResponseMetrics    ResponseMetrics
	InvokeResponseMode InvokeResponseMode
}

ResetFailure is the failure response to reset request

type ResetSuccess

type ResetSuccess struct {
	ExtensionsResetMs  int64
	ErrorType          fatalerror.ErrorType
	ResponseMetrics    ResponseMetrics
	InvokeResponseMode InvokeResponseMode
}

ResetSuccess is the success response to reset request

type ResponseMetrics

type ResponseMetrics struct {
	RuntimeOutboundThroughputBps int64
	RuntimeProducedBytes         int64
	RuntimeResponseLatencyMs     float64
	RuntimeTimeThrottledMs       int64
}

ResponseMetrics groups metrics related to the response stream

type ResponseMode

type ResponseMode string

ResponseMode are top-level constants used in combination with the various types of modes we have for responses, such as invoke's response mode and function's response mode. In the future we might have invoke's request mode or similar, so these help set the ground for consistency.

type Restore

type Restore struct {
	AwsKey               string
	AwsSecret            string
	AwsSession           string
	CredentialsExpiry    time.Time
	RestoreHookTimeoutMs int64
	LogStreamName        string
}

Restore message is sent to rapid to restore runtime to make it ready for consecutive invokes

type RestoreResult

type RestoreResult struct {
	RestoreMs int64
}

RestoreResult represents the result of `HandleRestore` function in RapidCore

type RestoreRuntimeDoneData

type RestoreRuntimeDoneData struct {
	Status    string      `json:"status"`
	ErrorType *string     `json:"errorType,omitempty"`
	Tracing   *TracingCtx `json:"tracing,omitempty"`
}

func (*RestoreRuntimeDoneData) String

func (d *RestoreRuntimeDoneData) String() string

type Resync

type Resync struct {
}

type RuntimeDoneInvokeMetrics

type RuntimeDoneInvokeMetrics struct {
	ProducedBytes int64   `json:"producedBytes"`
	DurationMs    float64 `json:"durationMs"`
}

type RuntimeInfo

type RuntimeInfo struct {
	ImageJSON string // image config, e.g {\"layers\":[]}
	Arn       string // runtime ARN, e.g. arn:awstest:lambda:us-west-2::runtime:python3.8::alpha
	Version   string // human-readable runtime arn equivalent, e.g. python3.8.v999
}

RuntimeInfo contains metadata about the runtime used by the Sandbox

type SandboxContext

type SandboxContext interface {
	Init(i *Init, timeoutMs int64) InitContext
	Reset(reset *Reset) (ResetSuccess, *ResetFailure)
	Shutdown(shutdown *Shutdown) ShutdownSuccess
	Restore(restore *Restore) (RestoreResult, error)

	// TODO: refactor this
	// runtimeStartedTime and InvokeResponseMetrics are needed to compute the runtimeDone metrics
	// in case of a Reset during an invoke (reset.reason=failure or reset.reason=timeout).
	// Ideally:
	// - the InvokeContext will have a Reset method to deal with Reset during an invoke and will hold runtimeStartedTime and InvokeResponseMetrics
	// - the SandboxContext will have its own Reset/Spindown method
	SetRuntimeStartedTime(invokeReceivedTime int64)
	SetInvokeResponseMetrics(metrics *InvokeResponseMetrics)
}

SandboxContext represents the sandbox lifecycle context

type SandboxInfoFromInit

type SandboxInfoFromInit struct {
	EnvironmentVariables *env.Environment // contains agent env vars (creds, customer, platform)
	SandboxType          SandboxType      // indicating Pre-Warmed, On-Demand etc
	RuntimeBootstrap     Bootstrap        // contains the runtime bootstrap binary path, Cwd, Args, Env, Cmd
}

SandboxInfoFromInit captures data from init request that is required during invoke (e.g. for suppressed init)

type SandboxType

type SandboxType string

SandboxType identifies sandbox type (PreWarmed vs Classic)

const SandboxClassic SandboxType = "Classic"
const SandboxPreWarmed SandboxType = "PreWarmed"

type Server

type Server interface {
	// GetCurrentInvokeID returns current invokeID.
	// NOTE, in case of INIT, when invokeID is not known in advance (e.g. provisioned concurrency),
	// returned invokeID will contain empty value.
	GetCurrentInvokeID() string

	// SendRuntimeReady sends a message indicating the runtime has called /invocation/next.
	// The checkpoint allows us to compute the overhead due to Extensions by substracting it
	// from the time when all extensions have called /next.
	// TODO: this method is a lifecycle event used only for metrics, and doesn't belong here
	SendRuntimeReady() error

	// SendInitErrorResponse does two separate things when init/error is called:
	// a) sends the init error response if called during invoke, and
	// b) notifies platform of a user fault if called, during both init or invoke
	// TODO:
	// separate the two concerns & unify with SendErrorResponse in response sender
	SendInitErrorResponse(response *ErrorInvokeResponse) error
}

Server used for sending messages and sharing data between the Runtime API handlers and the internal platform facing servers. For example,

responseCtx.SendResponse(...)

will send the response payload and metadata provided by the runtime to the platform, through the internal protocol used by the specific implementation TODO: rename this to InvokeResponseContext, used to send responses from handlers to platform-facing server

type Shutdown

type Shutdown struct {
	DeadlineNs int64
}

Shutdown message is sent to rapid to initiate graceful shutdown

type ShutdownSuccess

type ShutdownSuccess struct {
	ErrorType fatalerror.ErrorType
}

ShutdownSuccess is the response to a shutdown request

type Span

type Span struct {
	Name       string  `json:"name"`
	Start      string  `json:"start"`
	DurationMs float64 `json:"durationMs"`
}

func (*Span) String

func (s *Span) String() string

type StreamableInvokeResponse

type StreamableInvokeResponse struct {
	Headers  map[string]string
	Payload  io.Reader
	Trailers http.Header
	Request  *CancellableRequest // streaming request may need to gracefully terminate request streams
}

StreamableInvokeResponse represents a response received via Runtime API that can be streamed

type TelemetrySubscriptionMetrics

type TelemetrySubscriptionMetrics map[string]int

Metrics for response status of LogsAPI/TelemetryAPI `/subscribe` calls

func MergeSubscriptionMetrics

func MergeSubscriptionMetrics(logsAPIMetrics TelemetrySubscriptionMetrics, telemetryAPIMetrics TelemetrySubscriptionMetrics) TelemetrySubscriptionMetrics

type Token

type Token struct {
	ReservationToken         string
	InvokeID                 string
	VersionID                string
	FunctionTimeout          time.Duration
	InvackDeadlineNs         int64
	TraceID                  string
	LambdaSegmentID          string
	InvokeMetadata           string
	NeedDebugLogs            bool
	RestoreDurationNs        int64
	RestoreStartTimeMonotime int64
}

type TracingCtx

type TracingCtx struct {
	SpanID string            `json:"spanId,omitempty"`
	Type   model.TracingType `json:"type"`
	Value  string            `json:"value"`
}

Jump to

Keyboard shortcuts

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