mirror of
https://github.com/weaveworks/scope.git
synced 2026-02-14 18:09:59 +00:00
Fast start the dns resolution ticker to improve first report latency.
This commit is contained in:
@@ -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{}),
|
||||
|
||||
@@ -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...
|
||||
|
||||
Reference in New Issue
Block a user