appctx

package
v0.0.0-...-07bf88e Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const MaxRuntimeReleaseLength = 128

MaxRuntimeReleaseLength Max length for user agent string.

Variables

This section is empty.

Functions

func CreateRuntimeReleaseFromRequest

func CreateRuntimeReleaseFromRequest(request *http.Request, runtimeRelease string) string

CreateRuntimeReleaseFromRequest Gets runtime features from request header 'Lambda-Runtime-Features', and append it to the given runtime release.

func GetRuntimeRelease

func GetRuntimeRelease(appCtx ApplicationContext) string

GetRuntimeRelease returns runtime_release str extracted from app context.

func GetUserAgentFromRequest

func GetUserAgentFromRequest(request *http.Request) string

GetUserAgentFromRequest Returns the first token -seperated by a space- from request header 'User-Agent'.

func LoadFirstFatalError

func LoadFirstFatalError(appCtx ApplicationContext) (errorType fatalerror.ErrorType, found bool)

LoadFirstFatalError returns stored error if found

func LoadInteropServer

func LoadInteropServer(appCtx ApplicationContext) interop.Server

LoadInteropServer retrieves the interop server.

func LoadInvokeErrorTraceData

func LoadInvokeErrorTraceData(appCtx ApplicationContext) *interop.InvokeErrorTraceData

LoadInvokeErrorTraceData retrieves invocation error x-ray cause header from the application context.

func LoadResponseSender

func LoadResponseSender(appCtx ApplicationContext) interop.InvokeResponseSender

LoadResponseSender retrieves the response sender

func LoadSandboxType

func LoadSandboxType(appCtx ApplicationContext) interop.SandboxType

func RequestWithAppCtx

func RequestWithAppCtx(request *http.Request, appCtx ApplicationContext) *http.Request

RequestWithAppCtx places application context into request context.

func StoreFirstFatalError

func StoreFirstFatalError(appCtx ApplicationContext, err fatalerror.ErrorType)

StoreFirstFatalError stores unrecoverable error code in appctx once. This error is considered to be the rootcause of failure

func StoreInitType

func StoreInitType(appCtx ApplicationContext, initCachingEnabled bool)

func StoreInteropServer

func StoreInteropServer(appCtx ApplicationContext, server interop.Server)

StoreInteropServer stores a reference to the interop server.

func StoreInvokeErrorTraceData

func StoreInvokeErrorTraceData(appCtx ApplicationContext, invokeError *interop.InvokeErrorTraceData)

StoreInvokeErrorTraceData stores invocation error x-ray cause header in the applicaton context.

func StoreResponseSender

func StoreResponseSender(appCtx ApplicationContext, server interop.InvokeResponseSender)

StoreResponseSender stores a reference to the response sender

func StoreSandboxType

func StoreSandboxType(appCtx ApplicationContext, sandboxType interop.SandboxType)

func UpdateAppCtxWithRuntimeRelease

func UpdateAppCtxWithRuntimeRelease(request *http.Request, appCtx ApplicationContext) bool

UpdateAppCtxWithRuntimeRelease extracts runtime release info from user agent & lambda runtime features headers and update it into appCtx. Sample UA: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0

Types

type ApplicationContext

type ApplicationContext interface {
	Store(key Key, value interface{})
	Load(key Key) (value interface{}, ok bool)
	Delete(key Key)
	GetOrDefault(key Key, defaultValue interface{}) interface{}
	StoreIfNotExists(key Key, value interface{}) interface{}
}

ApplicationContext is an application scope context.

func FromRequest

func FromRequest(request *http.Request) ApplicationContext

FromRequest retrieves application context from the request context.

func NewApplicationContext

func NewApplicationContext() ApplicationContext

NewApplicationContext returns a new instance of application context.

type InitType

type InitType int
const (
	Init InitType = iota
	InitCaching
)

Possible values for AppCtxInitType key

func LoadInitType

func LoadInitType(appCtx ApplicationContext) InitType

Default Init Type is Init unless it's explicitly stored in ApplicationContext

type Key

type Key int

A Key type is used as a key for storing values in the application context.

const (
	// AppCtxInvokeErrorTraceDataKey is used for storing deferred invoke error cause header value.
	// Only used by xray. TODO refactor xray interface so it doesn't use appctx
	AppCtxInvokeErrorTraceDataKey Key = iota

	// AppCtxRuntimeReleaseKey is used for storing runtime release information (parsed from User_Agent Http header string).
	AppCtxRuntimeReleaseKey

	// AppCtxInteropServerKey is used to store a reference to the interop server.
	AppCtxInteropServerKey

	// AppCtxResponseSenderKey is used to store a reference to the response sender
	AppCtxResponseSenderKey

	// AppCtxFirstFatalErrorKey is used to store first unrecoverable error message encountered to propagate it to slicer with DONE(errortype) or DONEFAIL(errortype)
	AppCtxFirstFatalErrorKey

	// AppCtxInitType is used to store the init type (init caching or plain INIT)
	AppCtxInitType

	// AppCtxSandbox type is used to store the sandbox type (SandboxClassic or SandboxPreWarmed)
	AppCtxSandboxType
)

type ReqCtxKey

type ReqCtxKey int

A ReqCtxKey type is used as a key for storing values in the request context.

const ReqCtxApplicationContextKey ReqCtxKey = iota

ReqCtxApplicationContextKey is used for injecting application context object into request context.

Jump to

Keyboard shortcuts

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