(ctx *InvokeContext)
| 311 | } |
| 312 | |
| 313 | func (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 | |
| 363 | func (controller *Controller) tryGetRuntime(ctx *InvokeContext) (runtimeType string, err error) { |
| 364 | runtimeType = api.RuntimeViaUnknown |
no test coverage detected