{"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 core\n\nPackage core provides state objects and synchronization primitives for managing data flow in the system.\n\n### States {#hdr-States}\n\nRuntime and Agent implement state object design pattern.\n\nRuntime state interface:\n\n\ttype RuntimeState interface {\n\t\tInitError() error\n\t\tReady() error\n\t\tInvocationResponse() error\n\t\tInvocationErrorResponse() error\n\t}\n\n### Gates {#hdr-Gates}\n\nGates provide synchornization primitives for managing data flow in the system.\n\nGate is a synchronization aid that allows one or more threads to wait until a set of operations being performed in other threads completes.\n\nTo better understand gates, consider two examples below:\n\nExample 1: main thread is awaiting registered threads to walk through the gate,\n\n\tand after the last registered thread walked through the gate, gate\n\tcondition will be satisfied and main thread will proceed:\n\n\\[main] // register threads with the gate and start threads ... \\[main] g.AwaitGateCondition() \\[main] // blocked until gate condition is satisfied\n\n\\[thread] g.WalkThrough() \\[thread] // not blocked\n\nExample 2: main thread is awaiting registered threads to arrive at the gate,\n\n\tand after the last registered thread arrives at the gate, gate\n\tcondition will be satisfied and main thread, along with registered\n\tthreads will proceed:\n\n\\[main] // register threads with the gate and start threads ... \\[main] g.AwaitGateCondition() \\[main] // blocked until gate condition is satisfied\n\n### Flow {#hdr-Flow}\n\nFlow wraps a set of specific gates required to implement specific data flow in the system.\n\nExample flows would be INIT, INVOKE and RESET.\n\n### Registrations {#hdr-Registrations}\n\nRegistration service manages registrations, it maintains the mapping between registered parties are events they are registered. Parties not registered in the system will not be issued events.\n\n## Constants\n\n```go\nconst (\n\tAgentStartedStateName        = \"Started\"\n\tAgentRegisteredStateName     = \"Registered\"\n\tAgentReadyStateName          = \"Ready\"\n\tAgentRunningStateName        = \"Running\"\n\tAgentInitErrorStateName      = \"InitError\"\n\tAgentExitErrorStateName      = \"ExitError\"\n\tAgentShutdownFailedStateName = \"ShutdownFailed\"\n\tAgentExitedStateName         = \"Exited\"\n\tAgentLaunchErrorName         = \"LaunchError\"\n)\n```\nString values of possibles agent states\n\n```go\nconst (\n\tUNBLOCKED = iota\n\tBLOCKED\n)\n```\n\n```go\nconst (\n\tRuntimeStartedStateName   = \"Started\"\n\tRuntimeInitErrorStateName = \"InitError\"\n\tRuntimeReadyStateName     = \"Ready\"\n\tRuntimeRunningStateName   = \"Running\"\n\t// RuntimeStartedState -\u003e RuntimeRestoreReadyState\n\tRuntimeRestoreReadyStateName = \"RestoreReady\"\n\t// RuntimeRestoreReadyState -\u003e RuntimeRestoringState\n\tRuntimeRestoringStateName               = \"Restoring\"\n\tRuntimeInvocationResponseStateName      = \"InvocationResponse\"\n\tRuntimeInvocationErrorResponseStateName = \"InvocationErrorResponse\"\n\tRuntimeResponseSentStateName            = \"RuntimeResponseSentState\"\n\tRuntimeRestoreErrorStateName            = \"RuntimeRestoreErrorState\"\n)\n```\nString values of possibles runtime states\n\n```go\nconst MaxAgentsAllowed = 10\n```\n\n## Variables\n\n```go\nvar ErrAgentIDCollision = errors.New(\"ErrAgentIDCollision\")\n```\nErrAgentIDCollision means that agent with the same ID already exists in AgentsMap\n\n```go\nvar ErrAgentNameCollision = errors.New(\"ErrAgentNameCollision\")\n```\nErrAgentNameCollision means that agent with the same name already exists in AgentsMap\n\n```go\nvar ErrConcurrentStateModification = errors.New(\"Concurrent state modification\")\n```\nErrConcurrentStateModification returned when we've detected an invalid state transision caused by concurrent modification\n\n```go\nvar ErrCredentialsNotFound = fmt.Errorf(\"credentials not found for the provided token\")\n```\n\n```go\nvar ErrGateCanceled = errors.New(\"ErrGateCanceled\")\n```\nErrGateCanceled ...\n\n```go\nvar ErrGateIntegrity = errors.New(\"ErrGateIntegrity\")\n```\nErrGateIntegrity ...\n\n```go\nvar ErrNotAllowed = errors.New(\"State transition is not allowed\")\n```\nErrNotAllowed returned on illegal state transition\n\n```go\nvar ErrRegistrationServiceOff = errors.New(\"ErrRegistrationServiceOff\")\n```\nErrRegistrationServiceOff returned on attempt to register after registration service has been turned off.\n\n```go\nvar ErrTooManyExtensions = errors.New(\"ErrTooManyExtensions\")\n```\nErrTooManyExtensions means MaxAgentsAllowed limit is exceeded\n\n## Functions\n\n```go\nfunc ValidateExternalAgentEvent(e Event) error\n```\n\n```go\nfunc ValidateInternalAgentEvent(e Event) error\n```\n\n## Types\n\n```go\ntype AgentInfo struct {\n\tName          string\n\tState         string\n\tSubscriptions []string\n\tErrorType     string\n}\n```\nAgentInfo holds information about an agent renderable in customer logs\n\n```go\ntype AgentInfoErrorType string\n```\n\n```go\nconst (\n\tPermissionDenied  AgentInfoErrorType = \"PermissionDenied\"\n\tTooManyExtensions AgentInfoErrorType = \"TooManyExtensions\"\n\tUnknownError      AgentInfoErrorType = \"UnknownError\"\n)\n```\n\n```go\nfunc MapErrorToAgentInfoErrorType(err error) AgentInfoErrorType\n```\n\n```go\ntype Credentials struct {\n\tAwsKey     string    `json:\"AccessKeyId\"`\n\tAwsSecret  string    `json:\"SecretAccessKey\"`\n\tAwsSession string    `json:\"Token\"`\n\tExpiration time.Time `json:\"Expiration\"`\n}\n```\n\n```go\ntype CredentialsService interface {\n\tSetCredentials(token, awsKey, awsSecret, awsSession string, expiration time.Time)\n\tGetCredentials(token string) (*Credentials, error)\n\tUpdateCredentials(awsKey, awsSecret, awsSession string, expiration time.Time) error\n}\n```\n\n```go\nfunc NewCredentialsService() CredentialsService\n```\n\n```go\ntype Event string\n```\nEvent represents a platform event which agent can subscribe to\n\n```go\nconst (\n\t// InvokeEvent is dispatched when INVOKE happens\n\tInvokeEvent Event = \"INVOKE\"\n\t// ShutdownEvent is dispatched when SHUTDOWN or RESET happen\n\tShutdownEvent Event = \"SHUTDOWN\"\n)\n```\n\n```go\ntype ExternalAgent struct {\n\tName string\n\tID   uuid.UUID\n\n\tManagedThread Suspendable\n\n\tStartedState        ExternalAgentState\n\tRegisteredState     ExternalAgentState\n\tReadyState          ExternalAgentState\n\tRunningState        ExternalAgentState\n\tInitErrorState      ExternalAgentState\n\tExitErrorState      ExternalAgentState\n\tShutdownFailedState ExternalAgentState\n\tExitedState         ExternalAgentState\n\tLaunchErrorState    ExternalAgentState\n\t// contains filtered or unexported fields\n}\n```\nExternalAgent represents external agent\n\n```go\nfunc NewExternalAgent(name string, initFlow InitFlowSynchronization, invokeFlow InvokeFlowSynchronization) *ExternalAgent\n```\nNewExternalAgent returns new instance of a named agent\n\n```go\nfunc (s *ExternalAgent) ErrorType() string\n```\nErrorType returns error type reported during init or exit\n\n```go\nfunc (s *ExternalAgent) ExitError(errorType string) error\n```\nExitError - agent reported unrecoverable error\n\n```go\nfunc (s *ExternalAgent) Exited() error\n```\nExited - agent shut down successfully\n\n```go\nfunc (s *ExternalAgent) GetAgentDescription() statejson.ExtensionDescription\n```\nGetAgentDescription returns agent description object for debugging purposes\n\n```go\nfunc (s *ExternalAgent) GetState() ExternalAgentState\n```\nGetState returns agent's current state\n\n```go\nfunc (s *ExternalAgent) InitError(errorType string) error\n```\nInitError - agent registered but failed to initialize\n\n```go\nfunc (s *ExternalAgent) IsSubscribed(e Event) bool\n```\nIsSubscribed checks whether agent is subscribed the Event\n\n```go\nfunc (s *ExternalAgent) LaunchError(err error) error\n```\nExited - agent shut down successfully\n\n```go\nfunc (s *ExternalAgent) Ready() error\n```\nReady - mark an agent as ready\n\n```go\nfunc (s *ExternalAgent) Register(events []Event) error\n```\nRegister an agent with the platform\n\n```go\nfunc (s *ExternalAgent) Release()\n```\nRelease will resume a suspended thread\n\n```go\nfunc (s *ExternalAgent) SetState(state ExternalAgentState)\n```\nSetState using the lock\n\n```go\nfunc (s *ExternalAgent) ShutdownFailed() error\n```\nShutdownFailed - terminal state, agent didn't exit gracefully\n\n```go\nfunc (s *ExternalAgent) String() string\n```\n\n```go\nfunc (s *ExternalAgent) SubscribedEvents() []string\n```\nSubscribedEvents returns events to which the agent is subscribed\n\n```go\nfunc (s *ExternalAgent) SuspendUnsafe()\n```\nSuspendUnsafe the current running thread\n\n```go\ntype ExternalAgentExitErrorState struct {\n\t// contains filtered or unexported fields\n}\n```\nExternalAgentExitErrorState is a terminal state where agent has reported /exit/error\n\n```go\nfunc (s *ExternalAgentExitErrorState) ExitError(errorType string) error\n```\nExitError - multiple calls are allowed, but only the first submitted error is accepted\n\n```go\nfunc (s *ExternalAgentExitErrorState) Exited() error\n```\nExited\n\n```go\nfunc (s *ExternalAgentExitErrorState) InitError(errorType string) error\n```\nInitError\n\n```go\nfunc (s *ExternalAgentExitErrorState) LaunchError(error) error\n```\nLaunchError\n\n```go\nfunc (s *ExternalAgentExitErrorState) Name() string\n```\nName return state's human friendly name\n\n```go\nfunc (s *ExternalAgentExitErrorState) Ready() error\n```\nReady\n\n```go\nfunc (s *ExternalAgentExitErrorState) Register(events []Event) error\n```\nRegister\n\n```go\nfunc (s *ExternalAgentExitErrorState) ShutdownFailed() error\n```\nShutdownFailed\n\n```go\ntype ExternalAgentExitedState struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (s *ExternalAgentExitedState) ExitError(errorType string) error\n```\nExitError\n\n```go\nfunc (s *ExternalAgentExitedState) Exited() error\n```\nExited\n\n```go\nfunc (s *ExternalAgentExitedState) InitError(errorType string) error\n```\nInitError\n\n```go\nfunc (s *ExternalAgentExitedState) LaunchError(error) error\n```\nLaunchError\n\n```go\nfunc (s *ExternalAgentExitedState) Name() string\n```\nName return state's human friendly name\n\n```go\nfunc (s *ExternalAgentExitedState) Ready() error\n```\nReady\n\n```go\nfunc (s *ExternalAgentExitedState) Register(events []Event) error\n```\nRegister\n\n```go\nfunc (s *ExternalAgentExitedState) ShutdownFailed() error\n```\nShutdownFailed\n\n```go\ntype ExternalAgentInitErrorState struct {\n\t// contains filtered or unexported fields\n}\n```\nExternalAgentInitErrorState is a terminal state where agent has reported /init/error\n\n```go\nfunc (s *ExternalAgentInitErrorState) ExitError(errorType string) error\n```\nExitError\n\n```go\nfunc (s *ExternalAgentInitErrorState) Exited() error\n```\nExited\n\n```go\nfunc (s *ExternalAgentInitErrorState) InitError(errorType string) error\n```\nInitError - multiple calls are allowed, but only the first submitted error is accepted\n\n```go\nfunc (s *ExternalAgentInitErrorState) LaunchError(error) error\n```\nLaunchError\n\n```go\nfunc (s *ExternalAgentInitErrorState) Name() string\n```\nName return state's human friendly name\n\n```go\nfunc (s *ExternalAgentInitErrorState) Ready() error\n```\nReady\n\n```go\nfunc (s *ExternalAgentInitErrorState) Register(events []Event) error\n```\nRegister\n\n```go\nfunc (s *ExternalAgentInitErrorState) ShutdownFailed() error\n```\nShutdownFailed\n\n```go\ntype ExternalAgentLaunchErrorState struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (s *ExternalAgentLaunchErrorState) ExitError(errorType string) error\n```\nExitError\n\n```go\nfunc (s *ExternalAgentLaunchErrorState) Exited() error\n```\nExited\n\n```go\nfunc (s *ExternalAgentLaunchErrorState) InitError(errorType string) error\n```\nInitError\n\n```go\nfunc (s *ExternalAgentLaunchErrorState) LaunchError(error) error\n```\nLaunchError\n\n```go\nfunc (s *ExternalAgentLaunchErrorState) Name() string\n```\nName return state's human friendly name\n\n```go\nfunc (s *ExternalAgentLaunchErrorState) Ready() error\n```\nReady\n\n```go\nfunc (s *ExternalAgentLaunchErrorState) Register(events []Event) error\n```\nRegister\n\n```go\nfunc (s *ExternalAgentLaunchErrorState) ShutdownFailed() error\n```\nShutdownFailed\n\n```go\ntype ExternalAgentReadyState struct {\n\t// contains filtered or unexported fields\n}\n```\nExternalAgentReadyState is the state of an agent that reported ready to the platform\n\n```go\nfunc (s *ExternalAgentReadyState) ExitError(errorType string) error\n```\nExitError signals that agent provided unrecoverable error description\n\n```go\nfunc (s *ExternalAgentReadyState) Exited() error\n```\nExited\n\n```go\nfunc (s *ExternalAgentReadyState) InitError(errorType string) error\n```\nInitError\n\n```go\nfunc (s *ExternalAgentReadyState) LaunchError(error) error\n```\nLaunchError\n\n```go\nfunc (s *ExternalAgentReadyState) Name() string\n```\nName return state's human friendly name\n\n```go\nfunc (s *ExternalAgentReadyState) Ready() error\n```\nReady\n\n```go\nfunc (s *ExternalAgentReadyState) Register(events []Event) error\n```\nRegister\n\n```go\nfunc (s *ExternalAgentReadyState) ShutdownFailed() error\n```\nShutdownFailed\n\n```go\ntype ExternalAgentRegisteredState struct {\n\t// contains filtered or unexported fields\n}\n```\nExternalAgentRegisteredState is the state of an agent that registered with the platform but has not reported ready (next)\n\n```go\nfunc (s *ExternalAgentRegisteredState) ExitError(errorType string) error\n```\nExitError - agent called /exit/error\n\n```go\nfunc (s *ExternalAgentRegisteredState) Exited() error\n```\nExited\n\n```go\nfunc (s *ExternalAgentRegisteredState) InitError(errorType string) error\n```\nInitError - agent can transitions to InitErrorState if it failed to initialize\n\n```go\nfunc (s *ExternalAgentRegisteredState) LaunchError(error) error\n```\nLaunchError\n\n```go\nfunc (s *ExternalAgentRegisteredState) Name() string\n```\nName return state's human friendly name\n\n```go\nfunc (s *ExternalAgentRegisteredState) Ready() error\n```\nReady - agent has called next and is now successfully initialized\n\n```go\nfunc (s *ExternalAgentRegisteredState) Register(events []Event) error\n```\nRegister\n\n```go\nfunc (s *ExternalAgentRegisteredState) ShutdownFailed() error\n```\nShutdownFailed\n\n```go\ntype ExternalAgentRunningState struct {\n\t// contains filtered or unexported fields\n}\n```\nExternalAgentRunningState is the state of an agent that has received an invoke event and is currently processing it\n\n```go\nfunc (s *ExternalAgentRunningState) ExitError(errorType string) error\n```\nExitError signals that agent provided unrecoverable error description\n\n```go\nfunc (s *ExternalAgentRunningState) Exited() error\n```\nExited - agent process has exited\n\n```go\nfunc (s *ExternalAgentRunningState) InitError(errorType string) error\n```\nInitError\n\n```go\nfunc (s *ExternalAgentRunningState) LaunchError(error) error\n```\nLaunchError\n\n```go\nfunc (s *ExternalAgentRunningState) Name() string\n```\nName return state's human friendly name\n\n```go\nfunc (s *ExternalAgentRunningState) Ready() error\n```\nReady - agent transitions to Ready and the calling thread gets suspended. Upon release the agent transitions to Running\n\n```go\nfunc (s *ExternalAgentRunningState) Register(events []Event) error\n```\nRegister\n\n```go\nfunc (s *ExternalAgentRunningState) ShutdownFailed() error\n```\nShutdownFailed transitions agent into the ShutdownFailed terminal state\n\n```go\ntype ExternalAgentShutdownFailedState struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (s *ExternalAgentShutdownFailedState) ExitError(errorType string) error\n```\nExitError\n\n```go\nfunc (s *ExternalAgentShutdownFailedState) Exited() error\n```\nExited\n\n```go\nfunc (s *ExternalAgentShutdownFailedState) InitError(errorType string) error\n```\nInitError\n\n```go\nfunc (s *ExternalAgentShutdownFailedState) LaunchError(error) error\n```\nLaunchError\n\n```go\nfunc (s *ExternalAgentShutdownFailedState) Name() string\n```\nName return state's human friendly name\n\n```go\nfunc (s *ExternalAgentShutdownFailedState) Ready() error\n```\nReady\n\n```go\nfunc (s *ExternalAgentShutdownFailedState) Register(events []Event) error\n```\nRegister\n\n```go\nfunc (s *ExternalAgentShutdownFailedState) ShutdownFailed() error\n```\nShutdownFailed\n\n```go\ntype ExternalAgentStartedState struct {\n\t// contains filtered or unexported fields\n}\n```\nExternalAgentStartedState is the initial state of an external agent\n\n```go\nfunc (s *ExternalAgentStartedState) ExitError(errorType string) error\n```\nExitError\n\n```go\nfunc (s *ExternalAgentStartedState) Exited() error\n```\nExited\n\n```go\nfunc (s *ExternalAgentStartedState) InitError(errorType string) error\n```\nInitError\n\n```go\nfunc (s *ExternalAgentStartedState) LaunchError(err error) error\n```\nLaunchError signals that agent could not launch (non-exec/permission denied)\n\n```go\nfunc (s *ExternalAgentStartedState) Name() string\n```\nName return state's human friendly name\n\n```go\nfunc (s *ExternalAgentStartedState) Ready() error\n```\nReady\n\n```go\nfunc (s *ExternalAgentStartedState) Register(events []Event) error\n```\nRegister an agent with the platform when agent is in started state\n\n```go\nfunc (s *ExternalAgentStartedState) ShutdownFailed() error\n```\nShutdownFailed\n\n```go\ntype ExternalAgentState interface {\n\tRegister([]Event) error\n\tReady() error\n\tInitError(errorType string) error\n\tExitError(errorType string) error\n\tShutdownFailed() error\n\tExited() error\n\tLaunchError(error) error\n\tName() string\n}\n```\nExternalAgentState is external agent state interface\n\n```go\ntype ExternalAgentsMap struct {\n\t// contains filtered or unexported fields\n}\n```\nExternalAgentsMap stores Agents indexed by Name and ID\n\n```go\nfunc NewExternalAgentsMap() ExternalAgentsMap\n```\nNewExternalAgentsMap creates empty ExternalAgentsMap\n\n```go\nfunc (m *ExternalAgentsMap) AsArray() []*ExternalAgent\n```\nAsArray returns shallow copy of all agents as a single array. The order of agents is unspecified.\n\n```go\nfunc (m *ExternalAgentsMap) Clear()\n```\n\n```go\nfunc (m *ExternalAgentsMap) FindByID(id uuid.UUID) (agent *ExternalAgent, found bool)\n```\nFindByID finds agent by ID\n\n```go\nfunc (m *ExternalAgentsMap) FindByName(name string) (agent *ExternalAgent, found bool)\n```\nFindByName finds agent by name\n\n```go\nfunc (m *ExternalAgentsMap) Insert(a *ExternalAgent) error\n```\nInsert places agent into ExternalAgentsMap. Error is returned if agent with this ID or name already exists\n\n```go\nfunc (m *ExternalAgentsMap) Size() int\n```\nSize returns the number of agents contained in the datastructure\n\n```go\nfunc (m *ExternalAgentsMap) Visit(cb func(*ExternalAgent))\n```\nVisit iterates through agents, calling cb for each of them\n\n```go\ntype FunctionMetadata struct {\n\tAccountID         string\n\tFunctionName      string\n\tFunctionVersion   string\n\tInstanceMaxMemory uint64\n\tHandler           string\n\tRuntimeInfo       interop.RuntimeInfo\n}\n```\nFunctionMetadata holds static information regarding the function (Name, Version, Handler)\n\n```go\ntype Gate interface {\n\tRegister(count uint16)\n\tReset()\n\tSetCount(uint16) error\n\tWalkThrough() error\n\tAwaitGateCondition() error\n\tCancelWithError(error)\n\tClear()\n}\n```\nGate ...\n\n```go\nfunc NewGate(count uint16) Gate\n```\nNewGate returns new gate instance.\n\n```go\ntype InitFlowSynchronization interface {\n\tSetExternalAgentsRegisterCount(uint16) error\n\tSetAgentsReadyCount(uint16) error\n\n\tExternalAgentRegistered() error\n\tAwaitExternalAgentsRegistered() error\n\n\tRuntimeReady() error\n\tAwaitRuntimeReady() error\n\tAwaitRuntimeReadyWithDeadline(context.Context) error\n\n\tAgentReady() error\n\tAwaitAgentsReady() error\n\n\tCancelWithError(error)\n\n\tRuntimeRestoreReady() error\n\tAwaitRuntimeRestoreReady() error\n\n\tClear()\n}\n```\nInitFlowSynchronization wraps init flow barriers.\n\n```go\nfunc NewInitFlowSynchronization() InitFlowSynchronization\n```\nNewInitFlowSynchronization returns new InitFlowSynchronization instance.\n\n```go\ntype InternalAgent struct {\n\tName string\n\tID   uuid.UUID\n\n\tManagedThread Suspendable\n\n\tStartedState    InternalAgentState\n\tRegisteredState InternalAgentState\n\tRunningState    InternalAgentState\n\tReadyState      InternalAgentState\n\tInitErrorState  InternalAgentState\n\tExitErrorState  InternalAgentState\n\t// contains filtered or unexported fields\n}\n```\nInternalAgent represents internal agent\n\n```go\nfunc NewInternalAgent(name string, initFlow InitFlowSynchronization, invokeFlow InvokeFlowSynchronization) *InternalAgent\n```\nNewInternalAgent returns new instance of a named agent\n\n```go\nfunc (s *InternalAgent) ErrorType() string\n```\nErrorType returns error type reported during init or exit\n\n```go\nfunc (s *InternalAgent) ExitError(errorType string) error\n```\nExitError - agent registered but failed to initialize\n\n```go\nfunc (s *InternalAgent) GetAgentDescription() statejson.ExtensionDescription\n```\nGetAgentDescription returns agent description object for debugging purposes\n\n```go\nfunc (s *InternalAgent) GetState() InternalAgentState\n```\nGetState returns agent's current state\n\n```go\nfunc (s *InternalAgent) InitError(errorType string) error\n```\nInitError - agent registered but failed to initialize\n\n```go\nfunc (s *InternalAgent) IsSubscribed(e Event) bool\n```\nIsSubscribed checks whether agent is subscribed the Event\n\n```go\nfunc (s *InternalAgent) Ready() error\n```\nReady - mark an agent as ready\n\n```go\nfunc (s *InternalAgent) Register(events []Event) error\n```\nRegister an agent with the platform\n\n```go\nfunc (s *InternalAgent) Release()\n```\nRelease will resume a suspended thread\n\n```go\nfunc (s *InternalAgent) SetState(state InternalAgentState)\n```\nSetState using the lock\n\n```go\nfunc (s *InternalAgent) String() string\n```\n\n```go\nfunc (s *InternalAgent) SubscribedEvents() []string\n```\nSubscribedEvents returns events to which the agent is subscribed\n\n```go\nfunc (s *InternalAgent) SuspendUnsafe()\n```\nSuspendUnsafe the current running thread\n\n```go\ntype InternalAgentExitErrorState struct {\n\t// contains filtered or unexported fields\n}\n```\nInternalAgentExitErrorState is a terminal state where agent has reported /exit/error\n\n```go\nfunc (s *InternalAgentExitErrorState) ExitError(errorType string) error\n```\nExitError - multiple calls are allowed, but only the first submitted error is accepted\n\n```go\nfunc (s *InternalAgentExitErrorState) Exited() error\n```\nExited\n\n```go\nfunc (s *InternalAgentExitErrorState) InitError(errorType string) error\n```\nInitError\n\n```go\nfunc (s *InternalAgentExitErrorState) LaunchError(error) error\n```\nLaunchError\n\n```go\nfunc (s *InternalAgentExitErrorState) Name() string\n```\nName return state's human friendly name\n\n```go\nfunc (s *InternalAgentExitErrorState) Ready() error\n```\nReady\n\n```go\nfunc (s *InternalAgentExitErrorState) Register(events []Event) error\n```\nRegister\n\n```go\nfunc (s *InternalAgentExitErrorState) ShutdownFailed() error\n```\nShutdownFailed\n\n```go\ntype InternalAgentInitErrorState struct {\n\t// contains filtered or unexported fields\n}\n```\nInternalAgentInitErrorState is a terminal state where agent has reported /init/error\n\n```go\nfunc (s *InternalAgentInitErrorState) ExitError(errorType string) error\n```\nExitError\n\n```go\nfunc (s *InternalAgentInitErrorState) Exited() error\n```\nExited\n\n```go\nfunc (s *InternalAgentInitErrorState) InitError(errorType string) error\n```\nInitError - multiple calls are allowed, but only the first submitted error is accepted\n\n```go\nfunc (s *InternalAgentInitErrorState) LaunchError(error) error\n```\nLaunchError\n\n```go\nfunc (s *InternalAgentInitErrorState) Name() string\n```\nName return state's human friendly name\n\n```go\nfunc (s *InternalAgentInitErrorState) Ready() error\n```\nReady\n\n```go\nfunc (s *InternalAgentInitErrorState) Register(events []Event) error\n```\nRegister\n\n```go\nfunc (s *InternalAgentInitErrorState) ShutdownFailed() error\n```\nShutdownFailed\n\n```go\ntype InternalAgentReadyState struct {\n\t// contains filtered or unexported fields\n}\n```\nInternalAgentReadyState is the state of an agent that reported ready to the platform\n\n```go\nfunc (s *InternalAgentReadyState) ExitError(errorType string) error\n```\nExitError - agent called /exit/error\n\n```go\nfunc (s *InternalAgentReadyState) Exited() error\n```\nExited\n\n```go\nfunc (s *InternalAgentReadyState) InitError(errorType string) error\n```\nInitError\n\n```go\nfunc (s *InternalAgentReadyState) LaunchError(error) error\n```\nLaunchError\n\n```go\nfunc (s *InternalAgentReadyState) Name() string\n```\nName return state's human friendly name\n\n```go\nfunc (s *InternalAgentReadyState) Ready() error\n```\nReady\n\n```go\nfunc (s *InternalAgentReadyState) Register(events []Event) error\n```\nRegister\n\n```go\nfunc (s *InternalAgentReadyState) ShutdownFailed() error\n```\nShutdownFailed\n\n```go\ntype InternalAgentRegisteredState struct {\n\t// contains filtered or unexported fields\n}\n```\nInternalAgentRegisteredState is the state of an agent that registered with the platform but has not reported ready (next)\n\n```go\nfunc (s *InternalAgentRegisteredState) ExitError(errorType string) error\n```\nExitError - agent called /exit/error\n\n```go\nfunc (s *InternalAgentRegisteredState) Exited() error\n```\nExited\n\n```go\nfunc (s *InternalAgentRegisteredState) InitError(errorType string) error\n```\nInitError - agent can transitions to InitErrorState if it failed to initialize\n\n```go\nfunc (s *InternalAgentRegisteredState) LaunchError(error) error\n```\nLaunchError\n\n```go\nfunc (s *InternalAgentRegisteredState) Name() string\n```\nName return state's human friendly name\n\n```go\nfunc (s *InternalAgentRegisteredState) Ready() error\n```\nReady - agent has called next and is now successfully initialized\n\n```go\nfunc (s *InternalAgentRegisteredState) Register(events []Event) error\n```\nRegister\n\n```go\nfunc (s *InternalAgentRegisteredState) ShutdownFailed() error\n```\nShutdownFailed\n\n```go\ntype InternalAgentRunningState struct {\n\t// contains filtered or unexported fields\n}\n```\nInternalAgentRunningState is the state of an agent that is currently processing an event\n\n```go\nfunc (s *InternalAgentRunningState) ExitError(errorType string) error\n```\nExitError - agent called /exit/error\n\n```go\nfunc (s *InternalAgentRunningState) Exited() error\n```\nExited\n\n```go\nfunc (s *InternalAgentRunningState) InitError(errorType string) error\n```\nInitError\n\n```go\nfunc (s *InternalAgentRunningState) LaunchError(error) error\n```\nLaunchError\n\n```go\nfunc (s *InternalAgentRunningState) Name() string\n```\nName return state's human friendly name\n\n```go\nfunc (s *InternalAgentRunningState) Ready() error\n```\nReady - agent can transition from ready to ready\n\n```go\nfunc (s *InternalAgentRunningState) Register(events []Event) error\n```\nRegister\n\n```go\nfunc (s *InternalAgentRunningState) ShutdownFailed() error\n```\nShutdownFailed\n\n```go\ntype InternalAgentStartedState struct {\n\t// contains filtered or unexported fields\n}\n```\nInternalAgentStartedState is the initial state of an internal agent\n\n```go\nfunc (s *InternalAgentStartedState) ExitError(errorType string) error\n```\nExitError\n\n```go\nfunc (s *InternalAgentStartedState) Exited() error\n```\nExited\n\n```go\nfunc (s *InternalAgentStartedState) InitError(errorType string) error\n```\nInitError\n\n```go\nfunc (s *InternalAgentStartedState) LaunchError(error) error\n```\nLaunchError\n\n```go\nfunc (s *InternalAgentStartedState) Name() string\n```\nName return state's human friendly name\n\n```go\nfunc (s *InternalAgentStartedState) Ready() error\n```\nReady\n\n```go\nfunc (s *InternalAgentStartedState) Register(events []Event) error\n```\nRegister an agent with the platform when agent is in started state\n\n```go\nfunc (s *InternalAgentStartedState) ShutdownFailed() error\n```\nShutdownFailed\n\n```go\ntype InternalAgentState interface {\n\tRegister([]Event) error\n\tReady() error\n\tInitError(errorType string) error\n\tExitError(errorType string) error\n\tName() string\n}\n```\nInternalAgentState is internal agent state interface\n\n```go\ntype InternalAgentsMap struct {\n\t// contains filtered or unexported fields\n}\n```\nInternalAgentsMap stores Agents indexed by Name and ID\n\n```go\nfunc NewInternalAgentsMap() InternalAgentsMap\n```\nNewInternalAgentsMap creates empty InternalAgentsMap\n\n```go\nfunc (m *InternalAgentsMap) AsArray() []*InternalAgent\n```\nAsArray returns shallow copy of all agents as a single array. The order of agents is unspecified.\n\n```go\nfunc (m *InternalAgentsMap) Clear()\n```\n\n```go\nfunc (m *InternalAgentsMap) FindByID(id uuid.UUID) (agent *InternalAgent, found bool)\n```\nFindByID finds agent by ID\n\n```go\nfunc (m *InternalAgentsMap) FindByName(name string) (agent *InternalAgent, found bool)\n```\nFindByName finds agent by name\n\n```go\nfunc (m *InternalAgentsMap) Insert(a *InternalAgent) error\n```\nInsert places agent into InternalAgentsMap. Error is returned if agent with this ID or name already exists\n\n```go\nfunc (m *InternalAgentsMap) Size() int\n```\nSize returns the number of agents contained in the datastructure\n\n```go\nfunc (m *InternalAgentsMap) Visit(cb func(*InternalAgent))\n```\nVisit iterates through agents, calling cb for each of them\n\n```go\ntype InvokeFlowSynchronization interface {\n\tInitializeBarriers() error\n\tAwaitRuntimeResponse() error\n\tAwaitRuntimeReady() error\n\tRuntimeResponse(runtime *Runtime) error\n\tRuntimeReady(runtime *Runtime) error\n\tSetAgentsReadyCount(agentCount uint16) error\n\tAgentReady() error\n\tAwaitAgentsReady() error\n\tCancelWithError(error)\n\tClear()\n}\n```\nInvokeFlowSynchronization wraps invoke flow barriers.\n\n```go\nfunc NewInvokeFlowSynchronization() InvokeFlowSynchronization\n```\nNewInvokeFlowSynchronization returns new InvokeFlowSynchronization instance.\n\n```go\ntype ManagedThread struct {\n\t// contains filtered or unexported fields\n}\n```\nManagedThread is suspendable on operator condition.\n\n```go\nfunc NewManagedThread() *ManagedThread\n```\nNewManagedThread returns new ManagedThread instance.\n\n```go\nfunc (s *ManagedThread) Lock()\n```\nLock ManagedThread condvar mutex\n\n```go\nfunc (s *ManagedThread) Release()\n```\nRelease releases operator condition. This allows thread to be suspended and then resumed from the main thread.\n\n```go\nfunc (s *ManagedThread) SuspendUnsafe()\n```\nSuspendUnsafe suspends ManagedThread on operator condition. This allows thread to be suspended and then resumed from the main thread. It's marked Unsafe because ManagedThread should be locked before SuspendUnsafe is called\n\n```go\nfunc (s *ManagedThread) Unlock()\n```\nUnlock ManagedThread condvar mutex\n\n```go\ntype RegistrationService interface {\n\tCreateExternalAgent(agentName string) (*ExternalAgent, error)\n\tCreateInternalAgent(agentName string) (*InternalAgent, error)\n\tPreregisterRuntime(r *Runtime) error\n\tSetFunctionMetadata(metadata FunctionMetadata)\n\tGetFunctionMetadata() FunctionMetadata\n\tGetRuntime() *Runtime\n\tGetRegisteredAgentsSize() uint16\n\tFindExternalAgentByName(agentName string) (*ExternalAgent, bool)\n\tFindInternalAgentByName(agentName string) (*InternalAgent, bool)\n\tFindExternalAgentByID(agentID uuid.UUID) (*ExternalAgent, bool)\n\tFindInternalAgentByID(agentID uuid.UUID) (*InternalAgent, bool)\n\tTurnOff()\n\tInitFlow() InitFlowSynchronization\n\tGetInternalStateDescriptor(appCtx appctx.ApplicationContext) func() statejson.InternalStateDescription\n\tGetExternalAgents() []*ExternalAgent\n\tGetSubscribedExternalAgents(eventType Event) []*ExternalAgent\n\tGetSubscribedInternalAgents(eventType Event) []*InternalAgent\n\tCountAgents() int\n\tClear()\n\tAgentsInfo() []AgentInfo\n\tCancelFlows(err error)\n}\n```\nRegistrationService keeps track of registered parties, including external agents, threads, and runtime.\n\n```go\nfunc NewRegistrationService(initFlow InitFlowSynchronization, invokeFlow InvokeFlowSynchronization) RegistrationService\n```\nNewRegistrationService returns new RegistrationService instance.\n\n```go\ntype Runtime struct {\n\tManagedThread Suspendable\n\n\tRuntimeStartedState                 RuntimeState\n\tRuntimeInitErrorState               RuntimeState\n\tRuntimeReadyState                   RuntimeState\n\tRuntimeRunningState                 RuntimeState\n\tRuntimeRestoreReadyState            RuntimeState\n\tRuntimeRestoringState               RuntimeState\n\tRuntimeInvocationResponseState      RuntimeState\n\tRuntimeInvocationErrorResponseState RuntimeState\n\tRuntimeResponseSentState            RuntimeState\n\tRuntimeRestoreErrorState            RuntimeState\n\t// contains filtered or unexported fields\n}\n```\nRuntime is runtime object.\n\n```go\nfunc NewRuntime(initFlow InitFlowSynchronization, invokeFlow InvokeFlowSynchronization) *Runtime\n```\nNewRuntime returns new Runtime instance.\n\n```go\nfunc (s *Runtime) GetRuntimeDescription() statejson.RuntimeDescription\n```\nGetRuntimeDescription returns runtime description object for debugging purposes\n\n```go\nfunc (s *Runtime) GetState() RuntimeState\n```\nGetState ...\n\n```go\nfunc (s *Runtime) InitError() error\n```\nInitError delegates to state implementation.\n\n```go\nfunc (s *Runtime) InvocationErrorResponse() error\n```\nInvocationErrorResponse delegates to state implementation.\n\n```go\nfunc (s *Runtime) InvocationResponse() error\n```\nInvocationResponse delegates to state implementation.\n\n```go\nfunc (s *Runtime) Ready() error\n```\nReady delegates to state implementation.\n\n```go\nfunc (s *Runtime) Release()\n```\nRelease ...\n\n```go\nfunc (s *Runtime) ResponseSent() error\n```\nResponseSent delegates to state implementation.\n\n```go\nfunc (s *Runtime) RestoreError(UserError interop.FunctionError) error\n```\n\n```go\nfunc (s *Runtime) RestoreReady() error\n```\n\n```go\nfunc (s *Runtime) SetState(state RuntimeState)\n```\nSetState ...\n\n```go\ntype RuntimeInitErrorState struct {\n\t// contains filtered or unexported fields\n}\n```\nRuntimeInitErrorState runtime started state.\n\n```go\nfunc (s *RuntimeInitErrorState) InitError() error\n```\n\n```go\nfunc (s *RuntimeInitErrorState) InvocationErrorResponse() error\n```\n\n```go\nfunc (s *RuntimeInitErrorState) InvocationResponse() error\n```\n\n```go\nfunc (s *RuntimeInitErrorState) Name() string\n```\nName ...\n\n```go\nfunc (s *RuntimeInitErrorState) Ready() error\n```\n\n```go\nfunc (s *RuntimeInitErrorState) ResponseSent() error\n```\n\n```go\nfunc (s *RuntimeInitErrorState) RestoreError(interop.FunctionError) error\n```\n\n```go\nfunc (s *RuntimeInitErrorState) RestoreReady() error\n```\n\n```go\ntype RuntimeInvocationErrorResponseState struct {\n\t// contains filtered or unexported fields\n}\n```\nRuntimeInvocationErrorResponseState runtime response is available. Start state for runtime error response submission.\n\n```go\nfunc (s *RuntimeInvocationErrorResponseState) InitError() error\n```\n\n```go\nfunc (s *RuntimeInvocationErrorResponseState) InvocationErrorResponse() error\n```\n\n```go\nfunc (s *RuntimeInvocationErrorResponseState) InvocationResponse() error\n```\n\n```go\nfunc (s *RuntimeInvocationErrorResponseState) Name() string\n```\nName ...\n\n```go\nfunc (s *RuntimeInvocationErrorResponseState) Ready() error\n```\n\n```go\nfunc (s *RuntimeInvocationErrorResponseState) ResponseSent() error\n```\nResponseSent completes RuntimeInvocationErrorResponseState.\n\n```go\nfunc (s *RuntimeInvocationErrorResponseState) RestoreError(interop.FunctionError) error\n```\n\n```go\nfunc (s *RuntimeInvocationErrorResponseState) RestoreReady() error\n```\n\n```go\ntype RuntimeInvocationResponseState struct {\n\t// contains filtered or unexported fields\n}\n```\nRuntimeInvocationResponseState runtime response is available. Start state for runtime response submission.\n\n```go\nfunc (s *RuntimeInvocationResponseState) InitError() error\n```\n\n```go\nfunc (s *RuntimeInvocationResponseState) InvocationErrorResponse() error\n```\n\n```go\nfunc (s *RuntimeInvocationResponseState) InvocationResponse() error\n```\n\n```go\nfunc (s *RuntimeInvocationResponseState) Name() string\n```\nName ...\n\n```go\nfunc (s *RuntimeInvocationResponseState) Ready() error\n```\n\n```go\nfunc (s *RuntimeInvocationResponseState) ResponseSent() error\n```\nResponseSent completes RuntimeInvocationResponseState.\n\n```go\nfunc (s *RuntimeInvocationResponseState) RestoreError(interop.FunctionError) error\n```\n\n```go\nfunc (s *RuntimeInvocationResponseState) RestoreReady() error\n```\n\n```go\ntype RuntimeReadyState struct {\n\t// contains filtered or unexported fields\n}\n```\nRuntimeReadyState runtime ready state.\n\n```go\nfunc (s *RuntimeReadyState) InitError() error\n```\n\n```go\nfunc (s *RuntimeReadyState) InvocationErrorResponse() error\n```\n\n```go\nfunc (s *RuntimeReadyState) InvocationResponse() error\n```\n\n```go\nfunc (s *RuntimeReadyState) Name() string\n```\nName ...\n\n```go\nfunc (s *RuntimeReadyState) Ready() error\n```\n\n```go\nfunc (s *RuntimeReadyState) ResponseSent() error\n```\n\n```go\nfunc (s *RuntimeReadyState) RestoreError(interop.FunctionError) error\n```\n\n```go\nfunc (s *RuntimeReadyState) RestoreReady() error\n```\n\n```go\ntype RuntimeResponseSentState struct {\n\t// contains filtered or unexported fields\n}\n```\nRuntimeResponseSentState ends started runtime response or runtime error response submission.\n\n```go\nfunc (s *RuntimeResponseSentState) InitError() error\n```\n\n```go\nfunc (s *RuntimeResponseSentState) InvocationErrorResponse() error\n```\n\n```go\nfunc (s *RuntimeResponseSentState) InvocationResponse() error\n```\n\n```go\nfunc (s *RuntimeResponseSentState) Name() string\n```\nName ...\n\n```go\nfunc (s *RuntimeResponseSentState) Ready() error\n```\nReady call when runtime ready.\n\n```go\nfunc (s *RuntimeResponseSentState) ResponseSent() error\n```\n\n```go\nfunc (s *RuntimeResponseSentState) RestoreError(interop.FunctionError) error\n```\n\n```go\nfunc (s *RuntimeResponseSentState) RestoreReady() error\n```\n\n```go\ntype RuntimeRestoreErrorState struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (s *RuntimeRestoreErrorState) InitError() error\n```\n\n```go\nfunc (s *RuntimeRestoreErrorState) InvocationErrorResponse() error\n```\n\n```go\nfunc (s *RuntimeRestoreErrorState) InvocationResponse() error\n```\n\n```go\nfunc (s *RuntimeRestoreErrorState) Name() string\n```\n\n```go\nfunc (s *RuntimeRestoreErrorState) Ready() error\n```\n\n```go\nfunc (s *RuntimeRestoreErrorState) ResponseSent() error\n```\n\n```go\nfunc (s *RuntimeRestoreErrorState) RestoreError(interop.FunctionError) error\n```\n\n```go\nfunc (s *RuntimeRestoreErrorState) RestoreReady() error\n```\n\n```go\ntype RuntimeRestoreReadyState struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (s *RuntimeRestoreReadyState) InitError() error\n```\n\n```go\nfunc (s *RuntimeRestoreReadyState) InvocationErrorResponse() error\n```\n\n```go\nfunc (s *RuntimeRestoreReadyState) InvocationResponse() error\n```\n\n```go\nfunc (s *RuntimeRestoreReadyState) Name() string\n```\n\n```go\nfunc (s *RuntimeRestoreReadyState) Ready() error\n```\n\n```go\nfunc (s *RuntimeRestoreReadyState) ResponseSent() error\n```\n\n```go\nfunc (s *RuntimeRestoreReadyState) RestoreError(interop.FunctionError) error\n```\n\n```go\nfunc (s *RuntimeRestoreReadyState) RestoreReady() error\n```\n\n```go\ntype RuntimeRestoringState struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (s *RuntimeRestoringState) InitError() error\n```\n\n```go\nfunc (s *RuntimeRestoringState) InvocationErrorResponse() error\n```\n\n```go\nfunc (s *RuntimeRestoringState) InvocationResponse() error\n```\n\n```go\nfunc (s *RuntimeRestoringState) Name() string\n```\n\n```go\nfunc (s *RuntimeRestoringState) Ready() error\n```\nRuntime is healthy after restore and called /next\n\n```go\nfunc (s *RuntimeRestoringState) ResponseSent() error\n```\n\n```go\nfunc (s *RuntimeRestoringState) RestoreError(userError interop.FunctionError) error\n```\n\n```go\nfunc (s *RuntimeRestoringState) RestoreReady() error\n```\n\n```go\ntype RuntimeRunningState struct {\n\t// contains filtered or unexported fields\n}\n```\nRuntimeRunningState runtime ready state.\n\n```go\nfunc (s *RuntimeRunningState) InitError() error\n```\n\n```go\nfunc (s *RuntimeRunningState) InvocationErrorResponse() error\n```\nInvocationErrorResponse call when runtime error response is available.\n\n```go\nfunc (s *RuntimeRunningState) InvocationResponse() error\n```\nInvocationResponse call when runtime response is available.\n\n```go\nfunc (s *RuntimeRunningState) Name() string\n```\nName ...\n\n```go\nfunc (s *RuntimeRunningState) Ready() error\n```\n\n```go\nfunc (s *RuntimeRunningState) ResponseSent() error\n```\n\n```go\nfunc (s *RuntimeRunningState) RestoreError(interop.FunctionError) error\n```\n\n```go\nfunc (s *RuntimeRunningState) RestoreReady() error\n```\n\n```go\ntype RuntimeStartedState struct {\n\t// contains filtered or unexported fields\n}\n```\nRuntimeStartedState runtime started state.\n\n```go\nfunc (s *RuntimeStartedState) InitError() error\n```\nInitError move runtime to init error state.\n\n```go\nfunc (s *RuntimeStartedState) InvocationErrorResponse() error\n```\n\n```go\nfunc (s *RuntimeStartedState) InvocationResponse() error\n```\n\n```go\nfunc (s *RuntimeStartedState) Name() string\n```\nName ...\n\n```go\nfunc (s *RuntimeStartedState) Ready() error\n```\nReady call when runtime init done.\n\n```go\nfunc (s *RuntimeStartedState) ResponseSent() error\n```\n\n```go\nfunc (s *RuntimeStartedState) RestoreError(interop.FunctionError) error\n```\n\n```go\nfunc (s *RuntimeStartedState) RestoreReady() error\n```\n\n```go\ntype RuntimeState interface {\n\tInitError() error\n\tReady() error\n\tRestoreReady() error\n\tInvocationResponse() error\n\tInvocationErrorResponse() error\n\tResponseSent() error\n\tRestoreError(interop.FunctionError) error\n\tName() string\n}\n```\nRuntimeState is runtime state machine interface.\n\n```go\ntype Suspendable interface {\n\tSuspendUnsafe()\n\tRelease()\n\tLock()\n\tUnlock()\n}\n```\nSuspendable on operator condition.\n\n","path":"github.com/aws/aws-lambda-runtime-interface-emulator/internal/lambda/core","name":"core","synopsis":"Package core provides state objects and synchronization primitives for managing data flow in the system.","isRedistributable":true}
