MCPcopy Create free account
hub / github.com/tbphp/gpt-load / Match

Method Match

internal/failover/status_code_matcher.go:23–37  ·  view source on GitHub ↗

Match returns true if code is within any configured range.

(code int)

Source from the content-addressed store, hash-verified

21
22// Match returns true if code is within any configured range.
23func (m StatusCodeMatcher) Match(code int) bool {
24 if len(m.ranges) == 0 {
25 return false
26 }
27
28 // Find first range whose Start is greater than code, then check previous one.
29 i := sort.Search(len(m.ranges), func(i int) bool {
30 return m.ranges[i].Start > code
31 })
32 if i == 0 {
33 return false
34 }
35 r := m.ranges[i-1]
36 return code >= r.Start && code <= r.End
37}
38
39// IsEmpty reports whether the matcher has no ranges configured.
40func (m StatusCodeMatcher) IsEmpty() bool {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected