MCPcopy
hub / github.com/grpc-ecosystem/grpc-gateway / timeoutDecode

Function timeoutDecode

runtime/context.go:296–310  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

294}
295
296func timeoutDecode(s string) (time.Duration, error) {
297 size := len(s)
298 if size < 2 {
299 return 0, fmt.Errorf("timeout string is too short: %q", s)
300 }
301 d, ok := timeoutUnitToDuration(s[size-1])
302 if !ok {
303 return 0, fmt.Errorf("timeout unit is not recognized: %q", s)
304 }
305 t, err := strconv.ParseInt(s[:size-1], 10, 64)
306 if err != nil {
307 return 0, err
308 }
309 return d * time.Duration(t), nil
310}
311
312func timeoutUnitToDuration(u uint8) (d time.Duration, ok bool) {
313 switch u {

Callers 1

annotateContextFunction · 0.85

Calls 1

timeoutUnitToDurationFunction · 0.85

Tested by

no test coverage detected