Index: appengine/logdog/coordinator/endpoints/util.go |
diff --git a/appengine/logdog/coordinator/endpoints/util.go b/appengine/logdog/coordinator/endpoints/util.go |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f202b85ef352d7d6e8a48a8c326807ee9accc075 |
--- /dev/null |
+++ b/appengine/logdog/coordinator/endpoints/util.go |
@@ -0,0 +1,24 @@ |
+// 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 endpoints |
+ |
+import ( |
+ "time" |
+ |
+ "github.com/luci/luci-go/common/proto/google" |
+) |
+ |
+// MinDuration selects the smallest duration that is > 0 from a set of |
+// google.Duration protobufs. |
+// |
+// If none of the supplied Durations are > 0, 0 will be returned. |
+func MinDuration(candidates ...*google.Duration) (exp time.Duration) { |
+ for _, c := range candidates { |
+ if cd := c.Duration(); cd > 0 && (exp <= 0 || cd < exp) { |
+ exp = cd |
+ } |
+ } |
+ return |
+} |