Index: server/prpc/timeout.go |
diff --git a/server/prpc/timeout.go b/server/prpc/timeout.go |
deleted file mode 100644 |
index 9811395ff985f533ca6a1d928e5715b37bb040f6..0000000000000000000000000000000000000000 |
--- a/server/prpc/timeout.go |
+++ /dev/null |
@@ -1,65 +0,0 @@ |
-// Copyright 2016 The Chromium Authors. All rights reserved. |
-// Use of this source code is governed by a BSD-style license that can be |
-// found in the LICENSE file. |
- |
-package prpc |
- |
-import ( |
- "fmt" |
- "strconv" |
- "time" |
-) |
- |
-// headerTimeout is HTTP header used to set pRPC request timeout. |
-// The single value should match regexp `\d+[HMSmun]`. |
-const headerTimeout = "X-Prpc-Timeout" |
- |
-// The rest of this file is adapted from |
-// https://github.com/grpc/grpc-go/blob/6a026b9f108b49838491178e5d9bf7a4dcf32cf2/transport/http_util.go#L295 |
- |
-type timeoutUnit uint8 |
- |
-const ( |
- hour timeoutUnit = 'H' |
- minute timeoutUnit = 'M' |
- second timeoutUnit = 'S' |
- millisecond timeoutUnit = 'm' |
- microsecond timeoutUnit = 'u' |
- nanosecond timeoutUnit = 'n' |
-) |
- |
-func timeoutUnitToDuration(u timeoutUnit) (d time.Duration, ok bool) { |
- switch u { |
- case hour: |
- return time.Hour, true |
- case minute: |
- return time.Minute, true |
- case second: |
- return time.Second, true |
- case millisecond: |
- return time.Millisecond, true |
- case microsecond: |
- return time.Microsecond, true |
- case nanosecond: |
- return time.Nanosecond, true |
- default: |
- } |
- return |
-} |
- |
-func decodeTimeout(s string) (time.Duration, error) { |
- size := len(s) |
- if size < 2 { |
- return 0, fmt.Errorf("too short: %q", s) |
- } |
- unit := timeoutUnit(s[size-1]) |
- d, ok := timeoutUnitToDuration(unit) |
- if !ok { |
- return 0, fmt.Errorf("unit is not recognized: %q", s) |
- } |
- t, err := strconv.ParseInt(s[:size-1], 10, 64) |
- if err != nil { |
- return 0, err |
- } |
- return d * time.Duration(t), nil |
-} |