invoke

package
v0.0.0-...-4fa2157 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	СontentTypeHeader        = "content-type"
	FunctionErrorTypeTrailer = "lambda-runtime-function-error-type"
	FunctionErrorBodyTrailer = "lambda-runtime-function-error-body"
	ResponseModeHeader       = "invoke-response-mode"
	TraceIdHeader            = "x-amzn-trace-id"
)
View Source
const (
	ResponseLatencySpanName  = "responseLatency"
	ResponseDurationSpanName = "responseDuration"
)
View Source
const (
	InvokeTimeoutProperty = "InvokeTimeoutSeconds"

	RequestResponseModeDimension = "RequestMode"
	ResponseModeDimension        = "ResponseMode"

	RequestSendDurationMetric = "RequestSendDuration"

	RequestPayloadReadDurationMetric = "RequestPayloadReadDuration"

	RequestPayloadWriteDurationMetric = "RequestPayloadWriteDuration"
	ResponseLatencyMetric             = "ResponseLatency"
	ResponseDurationMetric            = "ResponseDuration"
	FunctionDurationMetric            = "FunctionDuration"
	RequestPayloadSizeBytesMetric     = "RequestPayloadSizeBytes"
	ResponsePayloadSizeBytesMetric    = "ResponsePayloadSizeBytes"

	ResponsePayloadReadDurationMetric = "ResponsePayloadReadDuration"

	ResponsePayloadWriteDurationMetric = "ResponsePayloadWriteDuration"
	ErrorPayloadSizeBytesMetric        = "ErrorPayloadSizeBytes"
	ResponseThrottledDurationMetric    = "ResponseThrottledDuration"
	ResponseThroughputMetric           = "ResponseThroughput"
	InflightRequestCountMetric         = "InflightRequestCount"
	IdleRuntimesCountMetric            = "IdleRuntimesCount"
)
View Source
const (
	RuntimeErrorTypeHeader     = "Lambda-Runtime-Function-Error-Type"
	RuntimeErrorCategory       = "Error.Runtime"
	LambdaXRayErrorCauseHeader = "Lambda-Runtime-Function-XRay-Error-Cause"
)
View Source
const (
	RuntimeContentTypeHeader     = "Content-Type"
	RuntimeRequestIdHeader       = "Lambda-Runtime-Aws-Request-Id"
	RuntimeDeadlineHeader        = "Lambda-Runtime-Deadline-Ms"
	RuntimeFunctionArnHeader     = "Lambda-Runtime-Invoked-Function-Arn"
	RuntimeTraceIdHeader         = "Lambda-Runtime-Trace-Id"
	RuntimeClientContextHeader   = "Lambda-Runtime-Client-Context"
	RuntimeCognitoIdentifyHeader = "Lambda-Runtime-Cognito-Identity"
)
View Source
const (
	RuntimeResponseModeHeader = "Lambda-Runtime-Function-Response-Mode"
)

Variables

View Source
var (
	ErrInvokeIdAlreadyExists = errors.New("invoke ID already exists")
	ErrInvokeNoReadyRuntime  = errors.New("no idle runtimes")
)

Functions

func BuildInvokeAppError

func BuildInvokeAppError(err error, invokeTimeout time.Duration) model.AppError

func NewInvokeMetrics

func NewInvokeMetrics(logger servicelogs.Logger, counter Counter) *invokeMetrics

func NewRuntimeError

func NewRuntimeError(ctx context.Context, request *http.Request, invokeID interop.InvokeID, errorDetails string) runtimeError

func NewRuntimeResponse

func NewRuntimeResponse(ctx context.Context, request *http.Request, invokeID interop.InvokeID) runtimeResponse

Types

type Counter

type Counter interface {
	AddInvoke(proxiedBytes uint64)
}

type ErrorForInvoker

type ErrorForInvoker interface {
	ReturnCode() int
	ErrorCategory() model.ErrorCategory
	ErrorType() model.ErrorType
	ErrorDetails() string
}

type InvokeBodyResponseStatus

type InvokeBodyResponseStatus string
const (
	InvokeBodyResponseComplete  InvokeBodyResponseStatus = "Complete"
	InvokeBodyResponseTruncated InvokeBodyResponseStatus = "Truncated"
)

type InvokeResponseSender

type InvokeResponseSender interface {
	SendRuntimeResponseHeaders(initData interop.InitStaticDataProvider, contentType, responseMode string)

	SendRuntimeResponseBody(ctx context.Context, runtimeResp RuntimeResponseRequest, functionTimeout time.Duration) SendResponseBodyResult

	SendRuntimeResponseTrailers(RuntimeResponseRequest)

	SendError(ErrorForInvoker, interop.InitStaticDataProvider)

	SendErrorTrailers(ErrorForInvoker, InvokeBodyResponseStatus)

	ErrorPayloadSizeBytes() int
}

type InvokeRouter

type InvokeRouter struct {
	// contains filtered or unexported fields
}

func NewInvokeRouter

func NewInvokeRouter(
	maxIdleRuntimesQueueSize int,
	telemetryEventsApi interop.EventsAPI,
	responderFactoryFunc ResponderFactoryFunc,
	timeoutCache timeoutCache,
) *InvokeRouter

func (*InvokeRouter) AbortRunningInvokes

func (ir *InvokeRouter) AbortRunningInvokes(metrics interop.ShutdownMetrics, err model.AppError)

func (*InvokeRouter) GetIdleRuntimesCount

func (ir *InvokeRouter) GetIdleRuntimesCount() int

func (*InvokeRouter) GetRunningInvokesCount

func (ir *InvokeRouter) GetRunningInvokesCount() int

func (*InvokeRouter) Invoke

func (ir *InvokeRouter) Invoke(ctx context.Context, initData interop.InitStaticDataProvider, invokeReq interop.InvokeRequest, metrics interop.InvokeMetrics) (err model.AppError, wasResponseSent bool)

func (*InvokeRouter) RuntimeError

func (ir *InvokeRouter) RuntimeError(ctx context.Context, runtimeErrReq RuntimeErrorRequest) model.AppError

func (*InvokeRouter) RuntimeNext

func (ir *InvokeRouter) RuntimeNext(ctx context.Context, runtimeReq http.ResponseWriter) (model.RuntimeNextWaiter, model.AppError)

func (*InvokeRouter) RuntimeResponse

func (ir *InvokeRouter) RuntimeResponse(ctx context.Context, runtimeRespReq RuntimeResponseRequest) model.AppError

type MockCounter

type MockCounter struct {
	mock.Mock
}

func NewMockCounter

func NewMockCounter(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockCounter

func (*MockCounter) AddInvoke

func (_m *MockCounter) AddInvoke(proxiedBytes uint64)

type MockErrorForInvoker

type MockErrorForInvoker struct {
	mock.Mock
}

func NewMockErrorForInvoker

func NewMockErrorForInvoker(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockErrorForInvoker

func (*MockErrorForInvoker) ErrorCategory

func (_m *MockErrorForInvoker) ErrorCategory() model.ErrorCategory

func (*MockErrorForInvoker) ErrorDetails

func (_m *MockErrorForInvoker) ErrorDetails() string

func (*MockErrorForInvoker) ErrorType

func (_m *MockErrorForInvoker) ErrorType() model.ErrorType

func (*MockErrorForInvoker) ReturnCode

func (_m *MockErrorForInvoker) ReturnCode() int

type MockInvokeResponseSender

type MockInvokeResponseSender struct {
	mock.Mock
}

func NewMockInvokeResponseSender

func NewMockInvokeResponseSender(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockInvokeResponseSender

func (*MockInvokeResponseSender) ErrorPayloadSizeBytes

func (_m *MockInvokeResponseSender) ErrorPayloadSizeBytes() int

func (*MockInvokeResponseSender) SendError

func (*MockInvokeResponseSender) SendErrorTrailers

func (_m *MockInvokeResponseSender) SendErrorTrailers(_a0 ErrorForInvoker, _a1 InvokeBodyResponseStatus)

func (*MockInvokeResponseSender) SendRuntimeResponseBody

func (_m *MockInvokeResponseSender) SendRuntimeResponseBody(ctx context.Context, runtimeResp RuntimeResponseRequest, functionTimeout time.Duration) SendResponseBodyResult

func (*MockInvokeResponseSender) SendRuntimeResponseHeaders

func (_m *MockInvokeResponseSender) SendRuntimeResponseHeaders(initData interop.InitStaticDataProvider, contentType string, responseMode string)

func (*MockInvokeResponseSender) SendRuntimeResponseTrailers

func (_m *MockInvokeResponseSender) SendRuntimeResponseTrailers(_a0 RuntimeResponseRequest)

type MockResponderFactoryFunc

type MockResponderFactoryFunc struct {
	mock.Mock
}

func NewMockResponderFactoryFunc

func NewMockResponderFactoryFunc(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockResponderFactoryFunc

func (*MockResponderFactoryFunc) Execute

type MockRuntimeErrorRequest

type MockRuntimeErrorRequest struct {
	mock.Mock
}

func NewMockRuntimeErrorRequest

func NewMockRuntimeErrorRequest(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockRuntimeErrorRequest

func (*MockRuntimeErrorRequest) ContentType

func (_m *MockRuntimeErrorRequest) ContentType() string

func (*MockRuntimeErrorRequest) ErrorCategory

func (_m *MockRuntimeErrorRequest) ErrorCategory() model.ErrorCategory

func (*MockRuntimeErrorRequest) ErrorDetails

func (_m *MockRuntimeErrorRequest) ErrorDetails() string

func (*MockRuntimeErrorRequest) ErrorType

func (_m *MockRuntimeErrorRequest) ErrorType() model.ErrorType

func (*MockRuntimeErrorRequest) GetError

func (_m *MockRuntimeErrorRequest) GetError() model.AppError

func (*MockRuntimeErrorRequest) GetXrayErrorCause

func (_m *MockRuntimeErrorRequest) GetXrayErrorCause() json.RawMessage

func (*MockRuntimeErrorRequest) InvokeID

func (_m *MockRuntimeErrorRequest) InvokeID() string

func (*MockRuntimeErrorRequest) IsRuntimeError

func (_m *MockRuntimeErrorRequest) IsRuntimeError(_a0 model.AppError) bool

func (*MockRuntimeErrorRequest) ReturnCode

func (_m *MockRuntimeErrorRequest) ReturnCode() int

type MockRuntimeResponseRequest

type MockRuntimeResponseRequest struct {
	mock.Mock
}

func NewMockRuntimeResponseRequest

func NewMockRuntimeResponseRequest(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockRuntimeResponseRequest

func (*MockRuntimeResponseRequest) BodyReader

func (_m *MockRuntimeResponseRequest) BodyReader() io.Reader

func (*MockRuntimeResponseRequest) ContentType

func (_m *MockRuntimeResponseRequest) ContentType() string

func (*MockRuntimeResponseRequest) InvokeID

func (_m *MockRuntimeResponseRequest) InvokeID() string

func (*MockRuntimeResponseRequest) ParsingError

func (_m *MockRuntimeResponseRequest) ParsingError() model.AppError

func (*MockRuntimeResponseRequest) ResponseMode

func (_m *MockRuntimeResponseRequest) ResponseMode() string

func (*MockRuntimeResponseRequest) TrailerError

func (_m *MockRuntimeResponseRequest) TrailerError() ErrorForInvoker

type RuntimeErrorRequest

type RuntimeErrorRequest interface {
	InvokeID() interop.InvokeID
	ContentType() string
	ErrorType() model.ErrorType
	ErrorCategory() model.ErrorCategory
	GetError() model.AppError
	IsRuntimeError(model.AppError) bool
	ReturnCode() int
	ErrorDetails() string
	GetXrayErrorCause() json.RawMessage
}

type RuntimeResponseRequest

type RuntimeResponseRequest interface {
	ParsingError() model.AppError

	InvokeID() interop.InvokeID
	ContentType() string
	ResponseMode() string

	BodyReader() io.Reader

	TrailerError() ErrorForInvoker
}

type SendResponseBodyResult

type SendResponseBodyResult struct {
	Metrics interop.InvokeResponseMetrics
	Err     model.AppError
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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