MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / getRuntime

Method getRuntime

pkg/controller/invoke.go:313–361  ·  view source on GitHub ↗
(ctx *InvokeContext)

Source from the content-addressed store, hash-verified

311}
312
313func (controller *Controller) getRuntime(ctx *InvokeContext) (err error) {
314 runtimeT := api.RuntimeViaUnknown
315 if ctx.RunOptions.RecommendedOptions.Features.EnableMetrics {
316 ctx.Metrics.StepStart(StageGetPodWarm)
317 ctx.Metrics.StepStart(StageGetPodCold)
318 defer func() {
319 if runtimeT == api.RuntimeViaWarm {
320 ctx.Metrics.StepDone(StageGetPodWarm)
321 ctx.Metrics.ScrapStage(StageGetPodCold)
322 } else if runtimeT == api.RuntimeViaCold {
323 ctx.Metrics.StepDone(StageGetPodCold)
324 ctx.Metrics.ScrapStage(StageGetPodWarm)
325 }
326
327 ctx.Metrics.SetLabel(podSourceLabel, runtimeT)
328 }()
329 }
330
331 ctx.Input = &rtctrl.InvocationInput{
332 ExternalRequestID: ctx.ExternalRequestID,
333 RequestID: ctx.RequestID,
334 User: ctx.OwnerUser,
335 Code: ctx.Function.Code,
336 Configuration: ctx.Function.Configuration,
337 LogConfig: ctx.Function.LogConfig,
338 EnableMetrics: ctx.RunOptions.RecommendedOptions.Features.EnableMetrics,
339 IsLogTail: ctx.LogType.IsLogTypeTail(),
340 Request: ctx.Request,
341 Response: ctx.Response,
342 Logger: ctx.Logger,
343 InvokeType: ctx.InvokeType,
344 TriggerType: ctx.TriggerType,
345 }
346
347 if ctx.WithStreamMode || strings.HasSuffix(ctx.Runtime.Name, "stream") {
348 ctx.WithStreamMode = true
349 ctx.Input.WithStreamMode = true
350 }
351 for i := 0; i < 2; i++ {
352 runtimeT, err = controller.tryGetRuntime(ctx)
353 if err != nil {
354 ctx.Logger.Errorf("#%d try to get runtime failed: %s", i, err.Error())
355 } else {
356 break
357 }
358 }
359
360 return
361}
362
363func (controller *Controller) tryGetRuntime(ctx *InvokeContext) (runtimeType string, err error) {
364 runtimeType = api.RuntimeViaUnknown

Callers 1

DoMethod · 0.95

Calls 8

tryGetRuntimeMethod · 0.95
StepStartMethod · 0.80
ScrapStageMethod · 0.80
SetLabelMethod · 0.80
IsLogTypeTailMethod · 0.80
ErrorfMethod · 0.80
StepDoneMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected