rapidcore

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: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RuntimeLogSink logSink = iota
	ExtensionLogSink
)
View Source
const RuntimeReleasePath = "/var/runtime/runtime-release"

Variables

View Source
var ErrAlreadyInvocating = errors.New("AlreadyInvocating")
View Source
var ErrAlreadyReplied = errors.New("AlreadyReplied")
View Source
var ErrAlreadyReserved = errors.New("AlreadyReserved")
View Source
var ErrInitDoneFailed = errors.New("InitDoneFailed")
View Source
var ErrInitNotStarted = errors.New("InitNotStarted")
View Source
var ErrInitResetReceived = errors.New("InitResetReceived")
View Source
var ErrInternalServerError = errors.New("InternalServerError")
View Source
var ErrInvokeDoneFailed = errors.New("InvokeDoneFailed")
View Source
var ErrInvokeReservationDone = errors.New("InvokeReservationDone")
View Source
var ErrInvokeResponseAlreadyWritten = errors.New("InvokeResponseAlreadyWritten")
View Source
var ErrInvokeTimeout = errors.New("InvokeTimeout")
View Source
var ErrNotReserved = errors.New("NotReserved")
View Source
var ErrReleaseReservationDone = errors.New("ReleaseReservationDone")
View Source
var ErrReserveReservationDone = errors.New("ReserveReservationDone")

Functions

func ParsePropertiesFile

func ParsePropertiesFile(path string) (map[string]string, error)

ParsePropertiesFile reads key-value pairs from file in newline-separated list of environment-like shell-compatible variable assignments. Format: https://www.freedesktop.org/software/systemd/man/os-release.html Value quotes are trimmed. Latest write wins for duplicated keys.

func SetInternalLogOutput

func SetInternalLogOutput(w io.Writer)

func SetLogLevel

func SetLogLevel(logLevel string)

SetLogLevel sets the log level for internal logging. Needs to be called very early during startup to configure logs emitted during initialization

Types

type DoneWithState

type DoneWithState struct {
	*interop.Done
	State statejson.InternalStateDescription
}

func (*DoneWithState) String

func (s *DoneWithState) String() string

type EmulatorAPI

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

EmulatorAPI wraps the standalone interop server to provide a convenient interface for Rapid Standalone

func NewEmulatorAPI

func NewEmulatorAPI(s *Server) *EmulatorAPI

func (*EmulatorAPI) Init

func (l *EmulatorAPI) Init(i *interop.Init, timeoutMs int64)

Init method is only used by the Runtime interface emulator

func (*EmulatorAPI) Invoke

Invoke method is only used by the Runtime interface emulator

type InvokeContext

type InvokeContext struct {
	Token       interop.Token
	ReplySent   bool
	ReplyStream http.ResponseWriter
	Direct      bool
}

type LambdaInvokeAPI

type LambdaInvokeAPI interface {
	Init(i *interop.Init, invokeTimeoutMs int64)
	Invoke(responseWriter http.ResponseWriter, invoke *interop.Invoke) error
}

LambdaInvokeAPI are the methods used by the Runtime Interface Emulator

type Logging

type Logging string
const (
	AmznStdout    Logging = "amzn-stdout"
	AmznStdoutTLV Logging = "amzn-stdout-tlv"
)

type ReserveResponse

type ReserveResponse struct {
	Token         interop.Token
	InternalState *statejson.InternalStateDescription
}

type RuntimeRelease

type RuntimeRelease struct {
	Name    string
	Version string
	Logging Logging
}

RuntimeRelease stores runtime identification data

func GetRuntimeRelease

func GetRuntimeRelease(path string) (*RuntimeRelease, error)

GetRuntimeRelease reads Runtime identification data from config file and parses it into a struct

type SandboxBuilder

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

func NewSandboxBuilder

func NewSandboxBuilder() *SandboxBuilder

func (*SandboxBuilder) AddShutdownFunc

func (b *SandboxBuilder) AddShutdownFunc(shutdownFunc func()) *SandboxBuilder

func (*SandboxBuilder) Create

func (*SandboxBuilder) DefaultInteropServer

func (b *SandboxBuilder) DefaultInteropServer() *Server

func (*SandboxBuilder) DisableStandaloneMode

func (b *SandboxBuilder) DisableStandaloneMode() *SandboxBuilder

func (*SandboxBuilder) LambdaInvokeAPI

func (b *SandboxBuilder) LambdaInvokeAPI() LambdaInvokeAPI

func (*SandboxBuilder) SetEventsAPI

func (b *SandboxBuilder) SetEventsAPI(eventsAPI interop.EventsAPI) *SandboxBuilder

func (*SandboxBuilder) SetExtensionsFlag

func (b *SandboxBuilder) SetExtensionsFlag(extensionsEnabled bool) *SandboxBuilder

func (*SandboxBuilder) SetHandler

func (b *SandboxBuilder) SetHandler(handler string) *SandboxBuilder

func (*SandboxBuilder) SetInitCachingFlag

func (b *SandboxBuilder) SetInitCachingFlag(initCachingEnabled bool) *SandboxBuilder

func (*SandboxBuilder) SetInteropServer

func (b *SandboxBuilder) SetInteropServer(interopServer interop.Server) *SandboxBuilder

func (*SandboxBuilder) SetLogsEgressAPI

func (b *SandboxBuilder) SetLogsEgressAPI(logsEgressAPI telemetry.StdLogsEgressAPI) *SandboxBuilder

func (*SandboxBuilder) SetRuntimeAPIAddress

func (b *SandboxBuilder) SetRuntimeAPIAddress(runtimeAPIAddress string) *SandboxBuilder

func (*SandboxBuilder) SetRuntimeFsRootPath

func (b *SandboxBuilder) SetRuntimeFsRootPath(rootPath string) *SandboxBuilder

func (*SandboxBuilder) SetSupervisor

func (b *SandboxBuilder) SetSupervisor(supervisor supvmodel.ProcessSupervisor) *SandboxBuilder

func (*SandboxBuilder) SetTelemetrySubscription

func (b *SandboxBuilder) SetTelemetrySubscription(logsSubscriptionAPI telemetry.SubscriptionAPI, telemetrySubscriptionAPI telemetry.SubscriptionAPI) *SandboxBuilder

func (*SandboxBuilder) SetTracer

func (b *SandboxBuilder) SetTracer(tracer telemetry.Tracer) *SandboxBuilder

type SandboxContext

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

SandboxContext and other structs form the implementation of the SandboxAPI interface defined in interop/sandbox_model.go, using the implementation of Init, Invoke and Reset handlers in rapid/sandbox.go

func (SandboxContext) Init

func (s SandboxContext) Init(init *interop.Init, timeoutMs int64) interop.InitContext

Init starts the runtime domain initialization in a separate goroutine. Return value indicates that init request has been accepted and started.

func (SandboxContext) Reset

Reset triggers a reset. In case of timeouts, the reset handler cancels all flows which triggers ongoing invoke handlers to return before proceeding with invoke TODO: move this method to the initialization context, since reset is conceptually on RT domain

func (SandboxContext) Restore

func (s SandboxContext) Restore(restore *interop.Restore) (interop.RestoreResult, error)

func (*SandboxContext) SetInvokeResponseMetrics

func (s *SandboxContext) SetInvokeResponseMetrics(metrics *interop.InvokeResponseMetrics)

func (*SandboxContext) SetRuntimeStartedTime

func (s *SandboxContext) SetRuntimeStartedTime(runtimeStartedTime int64)

func (SandboxContext) Shutdown

func (s SandboxContext) Shutdown(shutdown *interop.Shutdown) interop.ShutdownSuccess

Reset triggers a shutdown. This is similar to a reset, except that this is a terminal state and no further invokes are allowed

type Server

type Server struct {
	InternalStateGetter interop.InternalStateGetter

	InitDoneChan     chan DoneWithState
	InvokeDoneChan   chan DoneWithState
	ResetDoneChan    chan *interop.Done
	ShutdownDoneChan chan *interop.Done
	// contains filtered or unexported fields
}

func NewServer

func NewServer() *Server

func (*Server) AwaitInitialized

func (s *Server) AwaitInitialized() error

AwaitInitialized waits until init is complete. It must be idempotent, since it can be called twice when a caller wants to wait until init is complete

func (*Server) AwaitRelease

func (s *Server) AwaitRelease() (*statejson.ReleaseResponse, error)

func (*Server) Clear

func (s *Server) Clear()

func (*Server) CurrentToken

func (s *Server) CurrentToken() *interop.Token

func (*Server) FastInvoke

func (s *Server) FastInvoke(w http.ResponseWriter, i *interop.Invoke, direct bool) error

func (*Server) GetCurrentInvokeID

func (s *Server) GetCurrentInvokeID() string

GetCurrentInvokeID

func (*Server) GetInvokeContext

func (s *Server) GetInvokeContext() *InvokeContext

func (*Server) GetInvokeTimeout

func (s *Server) GetInvokeTimeout() time.Duration

func (*Server) Init

func (s *Server) Init(i *interop.Init, invokeTimeoutMs int64) error

func (*Server) InternalState

func (s *Server) InternalState() (*statejson.InternalStateDescription, error)

func (*Server) Invoke

func (s *Server) Invoke(responseWriter http.ResponseWriter, invoke *interop.Invoke) error

Invoke is used by the Runtime Interface Emulator (Rapid Local) https://github.com/aws/aws-lambda-runtime-interface-emulator

func (*Server) Release

func (s *Server) Release() error

Release closes the invocation, making server ready for reserve again

func (*Server) Reserve

func (s *Server) Reserve(id string, traceID, lambdaSegmentID string) (*ReserveResponse, error)

Reserve allocates invoke context

func (*Server) Reset

func (s *Server) Reset(reason string, timeoutMs int64) (*statejson.ResetDescription, error)

func (*Server) Restore

func (s *Server) Restore(restore *interop.Restore) (interop.RestoreResult, error)

func (*Server) SendErrorResponse

func (s *Server) SendErrorResponse(invokeID string, resp *interop.ErrorInvokeResponse) error

func (*Server) SendInitErrorResponse

func (s *Server) SendInitErrorResponse(resp *interop.ErrorInvokeResponse) error

func (*Server) SendResponse

func (s *Server) SendResponse(invokeID string, resp *interop.StreamableInvokeResponse) error

func (*Server) SendRuntimeReady

func (s *Server) SendRuntimeReady() error

func (*Server) SetInternalStateGetter

func (s *Server) SetInternalStateGetter(cb interop.InternalStateGetter)

SetInternalStateGetter is used to set callback which returnes internal state for /test/internalState request

func (*Server) SetInvokeTimeout

func (s *Server) SetInvokeTimeout(timeout time.Duration)

func (*Server) SetSandboxContext

func (s *Server) SetSandboxContext(sbCtx interop.SandboxContext)

SetSandboxContext is used to set the sandbox context after intiialization of interop server. After refactoring all messages, this needs to be removed and made an struct parameter on initialization.

func (*Server) Shutdown

func (s *Server) Shutdown(shutdown *interop.Shutdown) *statejson.InternalStateDescription

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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