refactor: introduce small helper

This commit is contained in:
Matthias Radestock committed 2014-12-24 13:29:13 +00:00
1 parent 108e468ada
commit 9cd652ef0b
1 file changed
+10 -9
+10 -9
View File
@@ -179,15 +179,9 @@ func (conn *LocalConnection) queryLoop(queryChan <-chan *ConnectionInteraction,
conn.log("error:", err)
break
}
if conn.heartbeat != nil {
heartbeat = conn.heartbeat.C
}
if conn.fetchAll != nil {
fetchAll = conn.fetchAll.C
}
if conn.fragTest != nil {
fragTest = conn.fragTest.C
}
heartbeat = tickerChan(conn.heartbeat)
fetchAll = tickerChan(conn.fetchAll)
fragTest = tickerChan(conn.fragTest)
select {
case query, ok := <-queryChan:
if !ok {
@@ -543,6 +537,13 @@ func (conn *LocalConnection) forwardHeartbeatFrame() {
conn.Forward(true, heartbeatFrame, nil)
}
func tickerChan(ticker *time.Ticker) <-chan time.Time {
if ticker != nil {
return ticker.C
}
return nil
}
func stopTicker(ticker *time.Ticker) {
if ticker != nil {
ticker.Stop()