negotiate idle connection state lifetime

work towards #20
This commit is contained in:
Marten Seemann
2016-05-14 16:48:19 +07:00
parent 43621c9c25
commit 16bd559d9a
6 changed files with 82 additions and 24 deletions

View File

@@ -58,6 +58,13 @@ func MaxDuration(a, b time.Duration) time.Duration {
return b
}
func MinDuration(a, b time.Duration) time.Duration {
if a > b {
return b
}
return a
}
// AbsDuration returns the absolute value of a time duration
func AbsDuration(d time.Duration) time.Duration {
if d >= 0 {

View File

@@ -33,6 +33,11 @@ var _ = Describe("Min / Max", func() {
Expect(MaxDuration(time.Microsecond, time.Nanosecond)).To(Equal(time.Microsecond))
Expect(MaxDuration(time.Nanosecond, time.Microsecond)).To(Equal(time.Microsecond))
})
It("returns the minimum duration", func() {
Expect(MinDuration(time.Microsecond, time.Nanosecond)).To(Equal(time.Nanosecond))
Expect(MinDuration(time.Nanosecond, time.Microsecond)).To(Equal(time.Nanosecond))
})
})
Context("Min", func() {