in lambda/rapid/sandbox.go [55:109]
func Start(ctx context.Context, s *Sandbox) (interop.RapidContext, interop.InternalStateGetter, string) {
// Initialize internal state objects required by Rapid handlers
appCtx := appctx.NewApplicationContext()
initFlow := core.NewInitFlowSynchronization()
invokeFlow := core.NewInvokeFlowSynchronization()
registrationService := core.NewRegistrationService(initFlow, invokeFlow)
renderingService := rendering.NewRenderingService()
credentialsService := core.NewCredentialsService()
appctx.StoreInitType(appCtx, s.InitCachingEnabled)
server := rapi.NewServer(s.RuntimeAPIHost, s.RuntimeAPIPort, appCtx, registrationService, renderingService, s.EnableTelemetryAPI, s.LogsSubscriptionAPI, s.TelemetrySubscriptionAPI, credentialsService)
runtimeAPIAddr := fmt.Sprintf("%s:%d", server.Host(), server.Port())
// TODO: pass this directly down to HTTP servers and handlers, instead of using
// global state to share the interop server implementation
appctx.StoreInteropServer(appCtx, s.InteropServer)
execCtx := &rapidContext{
// Internally initialized configurations
server: server,
appCtx: appCtx,
initDone: false,
initFlow: initFlow,
invokeFlow: invokeFlow,
registrationService: registrationService,
renderingService: renderingService,
credentialsService: credentialsService,
handlerExecutionMutex: sync.Mutex{},
shutdownContext: newShutdownContext(),
// Externally specified configurations (i.e. via SandboxBuilder)
telemetryAPIEnabled: s.EnableTelemetryAPI,
logsSubscriptionAPI: s.LogsSubscriptionAPI,
telemetrySubscriptionAPI: s.TelemetrySubscriptionAPI,
logsEgressAPI: s.LogsEgressAPI,
interopServer: s.InteropServer,
xray: s.Tracer,
standaloneMode: s.StandaloneMode,
eventsAPI: s.EventsAPI,
initCachingEnabled: s.InitCachingEnabled,
supervisor: processSupervisor{
ProcessSupervisor: s.Supervisor,
RootPath: s.RuntimeFsRootPath,
},
RuntimeStartedTime: -1,
RuntimeOverheadStartedTime: -1,
InvokeResponseMetrics: nil,
}
go startRuntimeAPI(ctx, execCtx)
return execCtx, registrationService.GetInternalStateDescriptor(appCtx), runtimeAPIAddr
}