Skip to content
Snippets Groups Projects
Commit 243ef5d7 authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

fixes logspam issues

parent 0e84f70f
No related branches found
No related tags found
No related merge requests found
...@@ -36,7 +36,6 @@ func init() { ...@@ -36,7 +36,6 @@ func init() {
// to support the gomobile Client interface // to support the gomobile Client interface
type Client struct { type Client struct {
api api.Client api api.Client
waitForNetwork chan bool
} }
// NewClient creates client storage, generates keys, connects, and registers // NewClient creates client storage, generates keys, connects, and registers
...@@ -225,41 +224,15 @@ func (c *Client) StopNetworkFollower(timeoutMS int) error { ...@@ -225,41 +224,15 @@ func (c *Client) StopNetworkFollower(timeoutMS int) error {
// WaitForNewtwork will block until either the network is healthy or the // WaitForNewtwork will block until either the network is healthy or the
// passed timeout. It will return true if the network is healthy // passed timeout. It will return true if the network is healthy
func (c *Client) WaitForNetwork(timeoutMS int) bool { func (c *Client) WaitForNetwork(timeoutMS int) bool {
timeout := time.NewTimer(time.Duration(timeoutMS) * time.Millisecond) start := time.Now()
if c.waitForNetwork == nil{ timeout := time.Duration(timeoutMS)*time.Millisecond
c.waitForNetwork = make(chan bool, 1) for time.Now().Sub(start)<timeout{
c.api.GetHealth().AddChannel(c.waitForNetwork)
}
//flush the channel if it is already full
select{
case <- c.waitForNetwork:
default:
}
// start a thread to check if healthy in a second in order to handle
// race conditions
go func() {
time.Sleep(1*time.Second)
if c.api.GetHealth().IsHealthy(){ if c.api.GetHealth().IsHealthy(){
select{
case c.waitForNetwork<-true:
default:
}
}
}()
//wait for network to be healthy or the timer to time out
for {
select{
case result := <- c.waitForNetwork:
if result {
return true return true
} }
case <-timeout.C: time.Sleep(250*time.Millisecond)
return false
}
} }
return false
} }
// Gets the state of the network follower. Returns: // Gets the state of the network follower. Returns:
......
...@@ -159,7 +159,7 @@ func (t *Tracker) transmit(health bool) { ...@@ -159,7 +159,7 @@ func (t *Tracker) transmit(health bool) {
select { select {
case c <- health: case c <- health:
default: default:
jww.WARN.Printf("Unable to send Health event") jww.DEBUG.Printf("Unable to send Health event")
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment