Fast start the dns resolution ticker to improve first report latency.

This commit is contained in:
Tom Wilkie
2016-05-12 11:47:56 +01:00
parent c41d1638ca
commit 310adc0d09
2 changed files with 28 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/rpc"
"sync"
@@ -20,6 +21,7 @@ import (
const (
initialBackoff = 1 * time.Second
maxBackoff = 60 * time.Second
dialTimeout = 5 * time.Second
)
// AppClient is a client to an app for dealing with controls.
@@ -64,6 +66,10 @@ func NewAppClient(pc ProbeConfig, hostname, target string, control xfer.ControlH
return nil, err
}
httpTransport.Dial = func(network, addr string) (net.Conn, error) {
return net.DialTimeout(network, addr, dialTimeout)
}
return &appClient{
ProbeConfig: pc,
quit: make(chan struct{}),

View File

@@ -17,9 +17,30 @@ const (
)
var (
tick = time.Tick
tick = fastStartTicker
)
// fastStartTicker is a ticker that 'ramps up' from 1 sec to duration.
func fastStartTicker(duration time.Duration) <-chan time.Time {
c := make(chan time.Time, 1)
go func() {
d := 1 * time.Second
for {
time.Sleep(d)
d = d * 2
if d > duration {
d = duration
}
select {
case c <- time.Now():
default:
}
}
}()
return c
}
type setter func(string, []string)
// Resolver is a thing that can be stopped...