MCPcopy Create free account
hub / github.com/InferCore/InferCore / InferBudgetHTTPStatus

Function InferBudgetHTTPStatus

internal/inferexec/budget.go:10–24  ·  view source on GitHub ↗

InferBudgetHTTPStatus returns 504 only when the infer-scoped context hit its deadline.

(ctx context.Context, err error)

Source from the content-addressed store, hash-verified

8
9// InferBudgetHTTPStatus returns 504 only when the infer-scoped context hit its deadline.
10func 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}

Calls

no outgoing calls