Skip to content

Commit

Permalink
remove global dnscache
Browse files Browse the repository at this point in the history
remove global dnscache
  • Loading branch information
jiuker committed Jul 9, 2024
1 parent 5346c47 commit 73e0dc0
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ const (
profilingPath = "/.pprof"
)

var dnsCache = &dnscache.Resolver{
Timeout: 5 * time.Second,
}

func init() {
// Create a new instance of the logger. You can have any number of instances.
log2 = logrus.New()
Expand Down Expand Up @@ -647,10 +643,11 @@ type roundTripperWrapper struct {
}

func (rtw *roundTripperWrapper) renew() {
dnsCache.Refresh()
tr := &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: dialContextWithDNSCache(dnsCache, newProxyDialContext(10*time.Second)),
Proxy: http.ProxyFromEnvironment,
DialContext: dialContextWithDNSCache(&dnscache.Resolver{
Timeout: 5 * time.Second,
}, newProxyDialContext(10*time.Second)),
MaxIdleConnsPerHost: 1024,
WriteBufferSize: 32 << 10, // 32KiB moving up from 4KiB default
ReadBufferSize: 32 << 10, // 32KiB moving up from 4KiB default
Expand Down Expand Up @@ -929,15 +926,6 @@ func sidekickMain(ctx *cli.Context) {
globalHostBalance = "least"
}

go func() {
t := time.NewTicker(ctx.GlobalDuration("dns-ttl"))
defer t.Stop()

for range t.C {
dnsCache.Refresh()
}
}()

if !strings.HasPrefix(healthCheckPath, slashSeparator) {
healthCheckPath = slashSeparator + healthCheckPath
}
Expand Down

0 comments on commit 73e0dc0

Please sign in to comment.