InferBudgetHTTPStatus returns 504 only when the infer-scoped context hit its deadline.
(ctx context.Context, err error)
| 8 | |
| 9 | // InferBudgetHTTPStatus returns 504 only when the infer-scoped context hit its deadline. |
| 10 | func InferBudgetHTTPStatus(ctx context.Context, err error) (status int, code string, ok bool) { |
| 11 | if err == nil { |
| 12 | return 0, "", false |
| 13 | } |
| 14 | if !errors.Is(err, context.DeadlineExceeded) { |
| 15 | return 0, "", false |
| 16 | } |
| 17 | if ctx.Err() == nil { |
| 18 | return 0, "", false |
| 19 | } |
| 20 | if errors.Is(ctx.Err(), context.DeadlineExceeded) { |
| 21 | return http.StatusGatewayTimeout, "gateway_timeout", true |
| 22 | } |
| 23 | return 0, "", false |
| 24 | } |
no outgoing calls