{"modulePath":"github.com/aws/aws-lambda-runtime-interface-emulator","version":"v0.0.0-20261030222936-bef5c4ba774d","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package interop\n\n## Constants\n\n```go\nconst (\n\tMaxPayloadSize = 6*1024*1024 + 100 // 6 MiB + 100 bytes\n\n\tResponseBandwidthRate      = 2 * 1024 * 1024 // default average rate of 2 MiB/s\n\tResponseBandwidthBurstSize = 6 * 1024 * 1024 // default burst size of 6 MiB\n\n\tMinResponseBandwidthRate = 32 * 1024        // 32 KiB/s\n\tMaxResponseBandwidthRate = 64 * 1024 * 1024 // 64 MiB/s\n\n\tMinResponseBandwidthBurstSize = 32 * 1024        // 32 KiB\n\tMaxResponseBandwidthBurstSize = 64 * 1024 * 1024 // 64 MiB\n)\n```\nMaxPayloadSize max event body size declared as LAMBDA\\_EVENT\\_BODY\\_SIZE\n\n```go\nconst (\n\tHTTPConnKey key = iota\n)\n```\n\n```go\nconst ResponseModeBuffered = \"Buffered\"\n```\n\n```go\nconst ResponseModeStreaming = \"Streaming\"\n```\n\n## Variables\n\n```go\nvar AllFunctionResponseModes = []string{\n\tstring(FunctionResponseModeBuffered), string(FunctionResponseModeStreaming),\n}\n```\n\n```go\nvar AllInvokeResponseModes = []string{\n\tstring(InvokeResponseModeBuffered), string(InvokeResponseModeStreaming),\n}\n```\n\n```go\nvar ErrCannotParseCredentialsExpiry = errors.New(\"errCannotParseCredentialsExpiry\")\n```\n\n```go\nvar ErrCannotParseRestoreHookTimeoutMs = errors.New(\"errCannotParseRestoreHookTimeoutMs\")\n```\n\n```go\nvar ErrInvalidFunctionResponseMode = fmt.Errorf(\"ErrInvalidFunctionResponseMode\")\n```\nErrInvalidFunctionResponseMode is returned when the value sent by runtime during Invoke2 is not a constant of type interop.FunctionResponseMode\n\n```go\nvar ErrInvalidFunctionVersion = fmt.Errorf(\"ErrInvalidFunctionVersion\")\n```\nErrInvalidFunctionVersion is returned when functionVersion provided in Invoke2 does not match one provided in Token\n\n```go\nvar ErrInvalidInvokeID = fmt.Errorf(\"ErrInvalidInvokeID\")\n```\nErrInvalidInvokeID is returned when invokeID provided in Invoke2 does not match one provided in Token\n\n```go\nvar ErrInvalidInvokeResponseMode = fmt.Errorf(\"ErrInvalidInvokeResponseMode\")\n```\nErrInvalidInvokeResponseMode is returned when optional InvokeResponseMode header provided in Invoke2 is not a constant of type interop.InvokeResponseMode\n\n```go\nvar ErrInvalidMaxPayloadSize = fmt.Errorf(\"ErrInvalidMaxPayloadSize\")\n```\nErrInvalidMaxPayloadSize is returned when optional MaxPayloadSize header provided in Invoke2 is invalid\n\n```go\nvar ErrInvalidReservationToken = fmt.Errorf(\"ErrInvalidReservationToken\")\n```\nErrInvalidReservationToken is returned when reservationToken provided in Invoke2 does not match one provided in Token\n\n```go\nvar ErrInvalidResponseBandwidthBurstSize = fmt.Errorf(\"ErrInvalidResponseBandwidthBurstSize\")\n```\nErrInvalidResponseBandwidthBurstSize is returned when optional ResponseBandwidthBurstSize header provided in Invoke2 is invalid\n\n```go\nvar ErrInvalidResponseBandwidthRate = fmt.Errorf(\"ErrInvalidResponseBandwidthRate\")\n```\nErrInvalidResponseBandwidthRate is returned when optional ResponseBandwidthRate header provided in Invoke2 is invalid\n\n```go\nvar ErrMalformedCustomerHeaders = fmt.Errorf(\"ErrMalformedCustomerHeaders\")\n```\nErrMalformedCustomerHeaders is returned when customer headers format is invalid\n\n```go\nvar ErrMissingRestoreCredentials = errors.New(\"errMissingRestoreCredentials\")\n```\n\n```go\nvar ErrReservationExpired = fmt.Errorf(\"ErrReservationExpired\")\n```\nErrReservationExpired is returned when invoke arrived after InvackDeadline\n\n```go\nvar ErrResponseSent = fmt.Errorf(\"ErrResponseSent\")\n```\nErrResponseSent is returned when response with given invokeID was already sent.\n\n```go\nvar ErrRestoreHookTimeout = errors.New(\"Runtime.RestoreHookUserTimeout\")\n```\nErrRestoreHookTimeout is returned as a response to \\`RESTORE\\` message when function's restore hook takes more time to execute thatn the timeout value.\n\n```go\nvar ErrRestoreUpdateCredentials = errors.New(\"errRestoreUpdateCredentials\")\n```\nErrRestoreUpdateCredentials is returned as a response to \\`RESTORE\\` message if RAPID cannot update the credentials served by credentials API during the RESTORE phase.\n\n## Functions\n\n```go\nfunc GetConn(r *http.Request) net.Conn\n```\n\n```go\nfunc IsResponseStreamingMetrics(metrics *InvokeResponseMetrics) bool\n```\n\n## Types\n\n```go\ntype Bootstrap interface {\n\tCmd() ([]string, error)                   // returns the args of bootstrap, where args[0] is the path to executable\n\tEnv(e *env.Environment) map[string]string // returns the environment variables to be passed to the bootstrapped process\n\tCwd() (string, error)                     // returns the working directory of the bootstrap process\n\tExtraFiles() []*os.File                   // returns the extra file descriptors apart from 1 \u0026 2 to be passed to runtime\n\tCachedFatalError(err error) (fatalerror.ErrorType, string, bool)\n}\n```\n\n```go\ntype CancellableRequest struct {\n\tRequest *http.Request\n}\n```\n\n```go\nfunc (c *CancellableRequest) Cancel() error\n```\n\n```go\ntype Done struct {\n\tWaitForExit bool\n\tErrorType   fatalerror.ErrorType\n\tMeta        DoneMetadata\n}\n```\n\n```go\nfunc DoneFromInvokeSuccess(successMsg InvokeSuccess) *Done\n```\n\n```go\ntype DoneFail struct {\n\tErrorType fatalerror.ErrorType\n\tMeta      DoneMetadata\n}\n```\n\n```go\nfunc DoneFailFromInitFailure(initFailure *InitFailure) *DoneFail\n```\n\n```go\nfunc DoneFailFromInvokeFailure(failureMsg *InvokeFailure) *DoneFail\n```\n\n```go\ntype DoneMetadata struct {\n\tNumActiveExtensions int\n\tExtensionsResetMs   int64\n\tExtensionNames      string\n\tRuntimeRelease      string\n\t// Metrics for response status of LogsAPI `/subscribe` calls\n\tLogsAPIMetrics               TelemetrySubscriptionMetrics\n\tInvokeRequestReadTimeNs      int64\n\tInvokeRequestSizeBytes       int64\n\tInvokeCompletionTimeNs       int64\n\tInvokeReceivedTime           int64\n\tRuntimeReadyTime             int64\n\tRuntimeResponseLatencyMs     float64\n\tRuntimeTimeThrottledMs       int64\n\tRuntimeProducedBytes         int64\n\tRuntimeOutboundThroughputBps int64\n\tMetricsDimensions            DoneMetadataMetricsDimensions\n}\n```\n\n```go\ntype DoneMetadataMetricsDimensions struct {\n\tInvokeResponseMode InvokeResponseMode\n}\n```\n\n```go\nfunc (dimensions DoneMetadataMetricsDimensions) String() string\n```\n\n```go\ntype DynamicDomainConfig struct {\n\t// extra hooks to execute at domain start. Currently used for filesystem and network hooks.\n\t// It can be empty.\n\tAdditionalStartHooks []model.Hook\n\tMounts               []model.Mount\n}\n```\nCaptures configuration of the operator and runtime domain that are only known after INIT is received\n\n```go\ntype EndData struct {\n\tRequestID RequestID `json:\"requestId\"`\n}\n```\n\n```go\nfunc (d *EndData) String() string\n```\n\n```go\ntype ErrInternalPlatformError struct{}\n```\nErrInternalPlatformError is returned when internal platform error occurred\n\n```go\nfunc (s *ErrInternalPlatformError) Error() string\n```\n\n```go\ntype ErrRestoreHookUserError struct {\n\tUserError FunctionError\n}\n```\nErrRestoreHookUserError 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.\n\n```go\nfunc (err ErrRestoreHookUserError) Error() string\n```\n\n```go\ntype ErrTruncatedResponse struct{}\n```\nErrTruncatedResponse is returned when response is truncated\n\n```go\nfunc (s *ErrTruncatedResponse) Error() string\n```\n\n```go\ntype ErrorInvokeResponse struct {\n\tHeaders       InvokeResponseHeaders\n\tPayload       []byte\n\tFunctionError FunctionError\n}\n```\nErrorInvokeResponse 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:\n\ndefault error response produced by the Slicer: '{\"errorMessage\":\"Unknown application error occurred\"}',\n\nwhen error type is provided, error response becomes: '{\"errorMessage\":\"Unknown application error occurred\",\"errorType\":\"ErrorType\"}'\n\n```go\nfunc GetErrorResponseWithFormattedErrorMessage(errorType fatalerror.ErrorType, err error, invokeRequestID string) *ErrorInvokeResponse\n```\n\n```go\ntype ErrorResponseTooLarge struct {\n\tMaxResponseSize int\n\tResponseSize    int\n}\n```\nErrorResponseTooLarge is returned when response Payload exceeds shared memory buffer size\n\n```go\nfunc (s *ErrorResponseTooLarge) AsErrorResponse() *ErrorInvokeResponse\n```\nAsErrorResponse generates ErrorInvokeResponse from ErrorResponseTooLarge\n\n```go\nfunc (s *ErrorResponseTooLarge) Error() string\n```\nErrorResponseTooLarge is returned when response provided by Runtime does not fit into shared memory buffer\n\n```go\ntype ErrorResponseTooLargeDI struct {\n\tErrorResponseTooLarge\n}\n```\nErrorResponseTooLargeDI is used to reproduce ErrorResponseTooLarge behavior for Direct Invoke mode\n\n```go\ntype EventsAPI interface {\n\tSetCurrentRequestID(RequestID)\n\tSendInitStart(InitStartData) error\n\tSendInitRuntimeDone(InitRuntimeDoneData) error\n\tSendInitReport(InitReportData) error\n\tSendRestoreRuntimeDone(RestoreRuntimeDoneData) error\n\tSendInvokeStart(InvokeStartData) error\n\tSendInvokeRuntimeDone(InvokeRuntimeDoneData) error\n\tSendExtensionInit(ExtensionInitData) error\n\tSendReportSpan(Span) error\n\tSendReport(ReportData) error\n\tSendEnd(EndData) error\n\tSendFault(FaultData) error\n\tSendImageErrorLog(ImageErrorLogData)\n\n\tFetchTailLogs(string) (string, error)\n\tGetRuntimeDoneSpans(\n\t\truntimeStartedTime int64,\n\t\tinvokeResponseMetrics *InvokeResponseMetrics,\n\t\truntimeOverheadStartedTime int64,\n\t\truntimeReadyTime int64,\n\t) []Span\n}\n```\n\n```go\ntype ExtensionInitData struct {\n\tAgentName     string   `json:\"name\"`\n\tState         string   `json:\"state\"`\n\tSubscriptions []string `json:\"events\"`\n\tErrorType     string   `json:\"errorType,omitempty\"`\n}\n```\n\n```go\nfunc (d *ExtensionInitData) String() string\n```\n\n```go\ntype FaultData struct {\n\tRequestID    RequestID\n\tErrorMessage error\n\tErrorType    fatalerror.ErrorType\n}\n```\n\n```go\nfunc (d *FaultData) String() string\n```\n\n```go\ntype FunctionError struct {\n\t// Type of error is derived from the Lambda-Runtime-Function-Error-Type set by the Runtime\n\t// This is customer data, so RAPID scrubs this error type to contain only allowlisted values\n\tType fatalerror.ErrorType `json:\"errorType,omitempty\"`\n\t// ErrorMessage is generated by RAPID and can never be specified by runtime\n\tMessage string `json:\"errorMessage,omitempty\"`\n}\n```\nFunctionError 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\n\n```go\ntype FunctionResponseMode string\n```\nFunctionResponseMode is passed by Runtime to tell whether the response should be streamed or not.\n\n```go\nconst FunctionResponseModeBuffered FunctionResponseMode = ResponseModeBuffered\n```\n\n```go\nconst FunctionResponseModeStreaming FunctionResponseMode = ResponseModeStreaming\n```\n\n```go\nfunc ConvertToFunctionResponseMode(value string) (FunctionResponseMode, error)\n```\nTODO: 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.\n\n```go\ntype ImageErrorLogData string\n```\n\n```go\ntype Init struct {\n\tInvokeID          string\n\tHandler           string\n\tAccountID         string\n\tAwsKey            string\n\tAwsSecret         string\n\tAwsSession        string\n\tCredentialsExpiry time.Time\n\tSuppressInit      bool\n\tInvokeTimeoutMs   int64  // timeout duration of whole invoke\n\tInitTimeoutMs     int64  // timeout duration for init only\n\tXRayDaemonAddress string // only in standalone\n\tFunctionName      string // only in standalone\n\tFunctionVersion   string // only in standalone\n\t// In standalone mode, these env vars come from test/init but from environment otherwise.\n\tCustomerEnvironmentVariables map[string]string\n\tSandboxType                  SandboxType\n\tLogStreamName                string\n\tInstanceMaxMemory            uint64\n\tOperatorDomainExtraConfig    DynamicDomainConfig\n\tRuntimeDomainExtraConfig     DynamicDomainConfig\n\tRuntimeInfo                  RuntimeInfo\n\tBootstrap                    Bootstrap\n\tEnvironmentVariables         *env.Environment // contains env vars for agents and runtime procs\n}\n```\nInit represents an init message In Rapid Shim, this is a START GirD message In Rapid Daemon, this is an INIT GirP message\n\n```go\ntype InitContext interface {\n\tWait() (InitSuccess, *InitFailure)\n\tReserve() InvokeContext\n}\n```\nInitContext represents the lifecycle of a sandbox initialization\n\n```go\ntype InitFailure struct {\n\tResetReceived       bool // indicates if failure happened due to a reset received\n\tRequestReset        bool // Indicates whether reset should be requested on init failure\n\tErrorType           fatalerror.ErrorType\n\tErrorMessage        error\n\tNumActiveExtensions int\n\tRuntimeRelease      string // value of the User Agent HTTP header provided by runtime\n\tLogsAPIMetrics      TelemetrySubscriptionMetrics\n\tAck                 chan struct{} // used by the sending goroutine to wait until ipc message has been sent\n}\n```\nInitFailure 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\n\n```go\ntype InitPhase string\n```\n\n```go\ntype InitReportData struct {\n\tInitializationType InitType          `json:\"initializationType\"`\n\tMetrics            InitReportMetrics `json:\"metrics\"`\n\tPhase              InitPhase         `json:\"phase\"`\n\tTracing            *TracingCtx       `json:\"tracing,omitempty\"`\n}\n```\n\n```go\nfunc (d *InitReportData) String() string\n```\n\n```go\ntype InitReportMetrics struct {\n\tDurationMs float64 `json:\"durationMs\"`\n}\n```\n\n```go\ntype InitRuntimeDoneData struct {\n\tInitializationType InitType    `json:\"initializationType\"`\n\tStatus             string      `json:\"status\"`\n\tPhase              InitPhase   `json:\"phase\"`\n\tErrorType          *string     `json:\"errorType,omitempty\"`\n\tTracing            *TracingCtx `json:\"tracing,omitempty\"`\n}\n```\n\n```go\nfunc (d *InitRuntimeDoneData) String() string\n```\n\n```go\ntype InitStartData struct {\n\tInitializationType InitType    `json:\"initializationType\"`\n\tRuntimeVersion     string      `json:\"runtimeVersion\"`\n\tRuntimeVersionArn  string      `json:\"runtimeVersionArn\"`\n\tFunctionName       string      `json:\"functionName\"`\n\tFunctionArn        string      `json:\"functionArn\"`\n\tFunctionVersion    string      `json:\"functionVersion\"`\n\tInstanceID         string      `json:\"instanceId\"`\n\tInstanceMaxMemory  uint64      `json:\"instanceMaxMemory\"`\n\tPhase              InitPhase   `json:\"phase\"`\n\tTracing            *TracingCtx `json:\"tracing,omitempty\"`\n}\n```\n\n```go\nfunc (d *InitStartData) String() string\n```\n\n```go\ntype InitSuccess struct {\n\tNumActiveExtensions int    // indicates number of active extensions\n\tExtensionNames      string // file names of extensions in /opt/extensions\n\tRuntimeRelease      string\n\tLogsAPIMetrics      TelemetrySubscriptionMetrics // used if telemetry API enabled\n\tAck                 chan struct{}                // used by the sending goroutine to wait until ipc message has been sent\n}\n```\nInitSuccess 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\n\n```go\ntype InitType string\n```\nInitializationType describes possible types of INIT phase\n\n```go\ntype InternalStateGetter func() statejson.InternalStateDescription\n```\n\n```go\ntype Invoke struct {\n\t// Tracing header.\n\t// https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-tracingheader\n\tTraceID                  string\n\tLambdaSegmentID          string\n\tID                       string\n\tTenantID                 TenantID\n\tInvokedFunctionArn       string\n\tCognitoIdentityID        string\n\tCognitoIdentityPoolID    string\n\tDeadlineNs               string\n\tClientContext            string\n\tContentType              string\n\tPayload                  io.Reader\n\tNeedDebugLogs            bool\n\tReservationToken         string\n\tVersionID                string\n\tInvokeReceivedTime       int64\n\tInvokeResponseMetrics    *InvokeResponseMetrics\n\tInvokeResponseMode       InvokeResponseMode\n\tRestoreDurationNs        int64 // equals 0 for non-snapstart functions\n\tRestoreStartTimeMonotime int64 // equals 0 for non-snapstart functions\n}\n```\nInvoke is an invocation request received from the slicer.\n\n```go\ntype InvokeContext interface {\n\tSendRequest(i *Invoke, r InvokeResponseSender)\n\tWait() (InvokeSuccess, *InvokeFailure)\n}\n```\nInvokeContext represents the lifecycle of a sandbox reservation\n\n```go\ntype InvokeErrorTraceData struct {\n\t// Attached to invoke segment\n\tErrorCause json.RawMessage `json:\"ErrorCause,omitempty\"`\n}\n```\nInvokeErrorTraceData is used by the tracer to mark segments as being invocation error\n\n```go\ntype InvokeFailure struct {\n\tResetReceived        bool // indicates if failure happened due to a reset received\n\tRequestReset         bool // indicates if reset must be requested after the failure\n\tErrorType            fatalerror.ErrorType\n\tErrorMessage         error\n\tRuntimeRelease       string // value of the User Agent HTTP header provided by runtime\n\tNumActiveExtensions  int\n\tInvokeReceivedTime   int64\n\tLogsAPIMetrics       TelemetrySubscriptionMetrics\n\tResponseMetrics      ResponseMetrics\n\tInvokeMetrics        InvokeMetrics\n\tExtensionNames       string\n\tDefaultErrorResponse *ErrorInvokeResponse // error resp constructed by platform during fn errors\n\tInvokeResponseMode   InvokeResponseMode\n}\n```\nInvokeFailure is the failure response to invoke phase end\n\n```go\ntype InvokeMetrics struct {\n\tInvokeRequestReadTimeNs int64\n\tInvokeRequestSizeBytes  int64\n\tRuntimeReadyTime        int64\n}\n```\nInvokeMetrics groups metrics related to the invoke phase\n\n```go\ntype InvokeResponseHeaders struct {\n\tContentType          string\n\tFunctionResponseMode string\n}\n```\nInvokeResponseHeaders contains the headers received via Runtime API /invocation/response\n\n```go\ntype InvokeResponseMetrics struct {\n\t// FIXME: this assumes a value in nanoseconds, let's rename it\n\t// to StartReadingResponseMonoTimeNs\n\tStartReadingResponseMonoTimeMs int64\n\t// Same as the one above\n\tFinishReadingResponseMonoTimeMs int64\n\tTimeShapedNs                    int64\n\tProducedBytes                   int64\n\tOutboundThroughputBps           int64 // in bytes per second\n\tFunctionResponseMode            FunctionResponseMode\n\tRuntimeCalledResponse           bool\n}\n```\nInvokeResponseMetrics are produced while sending streaming invoke response to WP\n\n```go\ntype InvokeResponseMode string\n```\n\n```go\nconst InvokeResponseModeBuffered InvokeResponseMode = ResponseModeBuffered\n```\n\n```go\nconst InvokeResponseModeStreaming InvokeResponseMode = ResponseModeStreaming\n```\n\n```go\ntype InvokeResponseSender interface {\n\t// SendResponse sends invocation response received from Runtime to platform\n\t// This is response may be streamed based on function and invoke response mode\n\tSendResponse(invokeID string, response *StreamableInvokeResponse) error\n\t// SendErrorResponse sends error response in the case of function errors, which are always buffered\n\tSendErrorResponse(invokeID string, response *ErrorInvokeResponse) error\n}\n```\n\n```go\ntype InvokeRuntimeDoneData struct {\n\tRequestID       RequestID                 `json:\"requestId\"`\n\tTenantID        TenantID                  `json:\"tenantId,omitempty\"`\n\tStatus          string                    `json:\"status\"`\n\tMetrics         *RuntimeDoneInvokeMetrics `json:\"metrics,omitempty\"`\n\tTracing         *TracingCtx               `json:\"tracing,omitempty\"`\n\tSpans           []Span                    `json:\"spans,omitempty\"`\n\tErrorType       *string                   `json:\"errorType,omitempty\"`\n\tInternalMetrics *InvokeResponseMetrics    `json:\"-\"`\n}\n```\n\n```go\nfunc (d *InvokeRuntimeDoneData) String() string\n```\n\n```go\ntype InvokeStartData struct {\n\tRequestID string      `json:\"requestId\"`\n\tTenantID  TenantID    `json:\"tenantId,omitempty\"`\n\tVersion   string      `json:\"version,omitempty\"`\n\tTracing   *TracingCtx `json:\"tracing,omitempty\"`\n}\n```\n\n```go\nfunc (d *InvokeStartData) String() string\n```\n\n```go\ntype InvokeSuccess struct {\n\tRuntimeRelease         string // value of the User Agent HTTP header provided by runtime\n\tNumActiveExtensions    int\n\tExtensionNames         string\n\tInvokeCompletionTimeNs int64\n\tInvokeReceivedTime     int64\n\tLogsAPIMetrics         TelemetrySubscriptionMetrics\n\tResponseMetrics        ResponseMetrics\n\tInvokeMetrics          InvokeMetrics\n\tInvokeResponseMode     InvokeResponseMode\n}\n```\nInvokeSuccess is the success response to invoke phase end\n\n```go\ntype LifecyclePhase int\n```\nLifecyclePhase represents enum for possible Sandbox lifecycle phases, like init, invoke, etc.\n\n```go\nconst (\n\tLifecyclePhaseInit LifecyclePhase = iota + 1\n\tLifecyclePhaseInvoke\n)\n```\n\n```go\ntype Message interface{}\n```\nMessage is a generic interop message.\n\n```go\ntype RapidContext interface {\n\tHandleInit(i *Init, success chan\u003c- InitSuccess, failure chan\u003c- InitFailure)\n\tHandleInvoke(i *Invoke, sbMetadata SandboxInfoFromInit, requestBuf *bytes.Buffer, responseSender InvokeResponseSender) (InvokeSuccess, *InvokeFailure)\n\tHandleReset(reset *Reset) (ResetSuccess, *ResetFailure)\n\tHandleShutdown(shutdown *Shutdown) ShutdownSuccess\n\tHandleRestore(restore *Restore) (RestoreResult, error)\n\tClear()\n\n\tSetRuntimeStartedTime(runtimeStartedTime int64)\n\tSetInvokeResponseMetrics(metrics *InvokeResponseMetrics)\n\n\tSetEventsAPI(eventsAPI EventsAPI)\n}\n```\nRapidContext expose methods for functionality of the Rapid Core library\n\n```go\ntype ReportData struct {\n\tRequestID RequestID     `json:\"requestId\"`\n\tTenantID  TenantID      `json:\"tenantId,omitempty\"`\n\tStatus    string        `json:\"status\"`\n\tMetrics   ReportMetrics `json:\"metrics\"`\n\tTracing   *TracingCtx   `json:\"tracing,omitempty\"`\n\tSpans     []Span        `json:\"spans,omitempty\"`\n\tErrorType *string       `json:\"errorType,omitempty\"`\n}\n```\n\n```go\nfunc (d *ReportData) String() string\n```\n\n```go\ntype ReportMetrics struct {\n\tDurationMs       float64 `json:\"durationMs\"`\n\tBilledDurationMs float64 `json:\"billedDurationMs\"`\n\tMemorySizeMB     uint64  `json:\"memorySizeMB\"`\n\tMaxMemoryUsedMB  uint64  `json:\"maxMemoryUsedMB\"`\n\tInitDurationMs   float64 `json:\"initDurationMs,omitempty\"`\n}\n```\n\n```go\ntype RequestID string\n```\n\n```go\ntype Reset struct {\n\tReason                string\n\tDeadlineNs            int64\n\tInvokeResponseMetrics *InvokeResponseMetrics\n\tTraceID               string\n\tLambdaSegmentID       string\n\tInvokeResponseMode    InvokeResponseMode\n}\n```\nReset message is sent to rapid to initiate reset sequence\n\n```go\ntype ResetFailure struct {\n\tExtensionsResetMs  int64\n\tErrorType          fatalerror.ErrorType\n\tResponseMetrics    ResponseMetrics\n\tInvokeResponseMode InvokeResponseMode\n}\n```\nResetFailure is the failure response to reset request\n\n```go\ntype ResetSuccess struct {\n\tExtensionsResetMs  int64\n\tErrorType          fatalerror.ErrorType\n\tResponseMetrics    ResponseMetrics\n\tInvokeResponseMode InvokeResponseMode\n}\n```\nResetSuccess is the success response to reset request\n\n```go\ntype ResponseMetrics struct {\n\tRuntimeOutboundThroughputBps int64\n\tRuntimeProducedBytes         int64\n\tRuntimeResponseLatencyMs     float64\n\tRuntimeTimeThrottledMs       int64\n}\n```\nResponseMetrics groups metrics related to the response stream\n\n```go\ntype ResponseMode string\n```\nResponseMode 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.\n\n```go\ntype Restore struct {\n\tAwsKey               string\n\tAwsSecret            string\n\tAwsSession           string\n\tCredentialsExpiry    time.Time\n\tRestoreHookTimeoutMs int64\n\tLogStreamName        string\n}\n```\nRestore message is sent to rapid to restore runtime to make it ready for consecutive invokes\n\n```go\ntype RestoreResult struct {\n\tRestoreMs int64\n}\n```\nRestoreResult represents the result of \\`HandleRestore\\` function in RapidCore\n\n```go\ntype RestoreRuntimeDoneData struct {\n\tStatus    string      `json:\"status\"`\n\tErrorType *string     `json:\"errorType,omitempty\"`\n\tTracing   *TracingCtx `json:\"tracing,omitempty\"`\n}\n```\n\n```go\nfunc (d *RestoreRuntimeDoneData) String() string\n```\n\n```go\ntype Resync struct {\n}\n```\n\n```go\ntype RuntimeDoneInvokeMetrics struct {\n\tProducedBytes int64   `json:\"producedBytes\"`\n\tDurationMs    float64 `json:\"durationMs\"`\n}\n```\n\n```go\ntype RuntimeInfo struct {\n\tImageJSON string // image config, e.g {\\\"layers\\\":[]}\n\tArn       string // runtime ARN, e.g. arn:awstest:lambda:us-west-2::runtime:python3.8::alpha\n\tVersion   string // human-readable runtime arn equivalent, e.g. python3.8.v999\n}\n```\nRuntimeInfo contains metadata about the runtime used by the Sandbox\n\n```go\ntype SandboxContext interface {\n\tInit(i *Init, timeoutMs int64) InitContext\n\tReset(reset *Reset) (ResetSuccess, *ResetFailure)\n\tShutdown(shutdown *Shutdown) ShutdownSuccess\n\tRestore(restore *Restore) (RestoreResult, error)\n\n\t// TODO: refactor this\n\t// runtimeStartedTime and InvokeResponseMetrics are needed to compute the runtimeDone metrics\n\t// in case of a Reset during an invoke (reset.reason=failure or reset.reason=timeout).\n\t// Ideally:\n\t// - the InvokeContext will have a Reset method to deal with Reset during an invoke and will hold runtimeStartedTime and InvokeResponseMetrics\n\t// - the SandboxContext will have its own Reset/Spindown method\n\tSetRuntimeStartedTime(invokeReceivedTime int64)\n\tSetInvokeResponseMetrics(metrics *InvokeResponseMetrics)\n}\n```\nSandboxContext represents the sandbox lifecycle context\n\n```go\ntype SandboxInfoFromInit struct {\n\tEnvironmentVariables *env.Environment // contains agent env vars (creds, customer, platform)\n\tSandboxType          SandboxType      // indicating Pre-Warmed, On-Demand etc\n\tRuntimeBootstrap     Bootstrap        // contains the runtime bootstrap binary path, Cwd, Args, Env, Cmd\n}\n```\nSandboxInfoFromInit captures data from init request that is required during invoke (e.g. for suppressed init)\n\n```go\ntype SandboxType string\n```\nSandboxType identifies sandbox type (PreWarmed vs Classic)\n\n```go\nconst SandboxClassic SandboxType = \"Classic\"\n```\n\n```go\nconst SandboxPreWarmed SandboxType = \"PreWarmed\"\n```\n\n```go\ntype Server interface {\n\t// GetCurrentInvokeID returns current invokeID.\n\t// NOTE, in case of INIT, when invokeID is not known in advance (e.g. provisioned concurrency),\n\t// returned invokeID will contain empty value.\n\tGetCurrentInvokeID() string\n\n\t// SendRuntimeReady sends a message indicating the runtime has called /invocation/next.\n\t// The checkpoint allows us to compute the overhead due to Extensions by substracting it\n\t// from the time when all extensions have called /next.\n\t// TODO: this method is a lifecycle event used only for metrics, and doesn't belong here\n\tSendRuntimeReady() error\n\n\t// SendInitErrorResponse does two separate things when init/error is called:\n\t// a) sends the init error response if called during invoke, and\n\t// b) notifies platform of a user fault if called, during both init or invoke\n\t// TODO:\n\t// separate the two concerns \u0026 unify with SendErrorResponse in response sender\n\tSendInitErrorResponse(response *ErrorInvokeResponse) error\n}\n```\nServer used for sending messages and sharing data between the Runtime API handlers and the internal platform facing servers. For example,\n\n\tresponseCtx.SendResponse(...)\n\nwill 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\n\n```go\ntype Shutdown struct {\n\tDeadlineNs int64\n}\n```\nShutdown message is sent to rapid to initiate graceful shutdown\n\n```go\ntype ShutdownSuccess struct {\n\tErrorType fatalerror.ErrorType\n}\n```\nShutdownSuccess is the response to a shutdown request\n\n```go\ntype Span struct {\n\tName       string  `json:\"name\"`\n\tStart      string  `json:\"start\"`\n\tDurationMs float64 `json:\"durationMs\"`\n}\n```\n\n```go\nfunc (s *Span) String() string\n```\n\n```go\ntype StreamableInvokeResponse struct {\n\tHeaders  map[string]string\n\tPayload  io.Reader\n\tTrailers http.Header\n\tRequest  *CancellableRequest // streaming request may need to gracefully terminate request streams\n}\n```\nStreamableInvokeResponse represents a response received via Runtime API that can be streamed\n\n```go\ntype TelemetrySubscriptionMetrics map[string]int\n```\nMetrics for response status of LogsAPI/TelemetryAPI \\`/subscribe\\` calls\n\n```go\nfunc MergeSubscriptionMetrics(logsAPIMetrics TelemetrySubscriptionMetrics, telemetryAPIMetrics TelemetrySubscriptionMetrics) TelemetrySubscriptionMetrics\n```\n\n```go\ntype TenantID string\n```\n\n```go\ntype Token struct {\n\tReservationToken         string\n\tInvokeID                 string\n\tTenantID                 TenantID\n\tVersionID                string\n\tFunctionTimeout          time.Duration\n\tInvackDeadlineNs         int64\n\tTraceID                  string\n\tLambdaSegmentID          string\n\tInvokeMetadata           string\n\tNeedDebugLogs            bool\n\tRestoreDurationNs        int64\n\tRestoreStartTimeMonotime int64\n}\n```\n\n```go\ntype TracingCtx struct {\n\tSpanID string            `json:\"spanId,omitempty\"`\n\tType   model.TracingType `json:\"type\"`\n\tValue  string            `json:\"value\"`\n}\n```\n\n","path":"github.com/aws/aws-lambda-runtime-interface-emulator/internal/lambda/interop","name":"interop","synopsis":"","isRedistributable":true}
