func startRuntimeAPILoop()

in fc/invoke_loop.go [30:52]


func startRuntimeAPILoop(ctx context.Context, api string, baseHandler handlerWrapper, lifeCycleHandlers []handlerWrapper) (e error) {
	defer func() {
		if r := recover(); r != nil {
			e = fmt.Errorf("%v", r)
		}
	}()
	client := newRuntimeAPIClient(api)
	function := NewFunction(baseHandler.handler, baseHandler.funcType).withContext(ctx)
	function.RegistryLifeCycleHandler(lifeCycleHandlers)
	for {
		req, err := client.next()
		if err != nil {
			logPrintf("failed to get invoke request due to %v", err)
			continue
		}
		go func(req *invoke, f *Function) {
			err = handleInvoke(req, f)
			if err != nil {
				logPrintf("failed to invoke function due to %v", err)
			}
		}(req, function)
	}
}