commit 8a8273e972f8a0d9496da7f6af47e34899c07f14 Author: Serene Han keroserene+git@gmail.com Date: Sun Feb 28 13:16:12 2016 -0800
use const LogTimeInterval --- client/util.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/client/util.go b/client/util.go index fa04220..abefa04 100644 --- a/client/util.go +++ b/client/util.go @@ -5,6 +5,10 @@ import ( "time" )
+const ( + LogTimeInterval = 5 +) + type BytesInfo struct { outboundChan chan int inboundChan chan int @@ -33,18 +37,18 @@ func (b *BytesInfo) Log() { b.outbound += amount b.outEvents++ last := time.Now() - if time.Since(last) > time.Second*5 { + if time.Since(last) > time.Second*LogTimeInterval { last = time.Now() output() } case amount = <-b.inboundChan: b.inbound += amount b.inEvents++ - if time.Since(last) > time.Second*5 { + if time.Since(last) > time.Second*LogTimeInterval { last = time.Now() output() } - case <-time.After(time.Second * 5): + case <-time.After(time.Second * LogTimeInterval): if b.inEvents > 0 || b.outEvents > 0 { output() }