Skip to content

Commit

Permalink
Memoize DialContext's for 60 minutes and expose it as a configurable …
Browse files Browse the repository at this point in the history
…variable

Signed-off-by: Brian Dwyer <[email protected]>
  • Loading branch information
bdwyertech committed Mar 23, 2021
1 parent cb3eadd commit 16a96aa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/gontlm-proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var ProxyUser = os.Getenv("GONTLM_USER")
var ProxyPass = os.Getenv("GONTLM_PASS")
var ProxyDomain = os.Getenv("GONTLM_DOMAIN")
var ProxyOverrides *map[string]*url.URL
var ProxyDialerCacheTimeout = 60 * time.Minute

func Run() {
proxy := goproxy.NewProxyHttpServer()
Expand Down Expand Up @@ -80,10 +81,10 @@ func Run() {
}

//
// LRU Cache: Memoize DialContexts for 30 minutes
// LRU Cache: Memoize DialContexts for 60 minutes
//
dialerCache := ttlcache.NewCache()
dialerCache.SetTTL(time.Duration(30 * time.Minute))
dialerCache.SetTTL(ProxyDialerCacheTimeout)
dialerCacheGroup := singleflight.Group{}

proxyDialer := func(scheme, addr string, pxyUrl *url.URL) proxyplease.DialContext {
Expand Down

0 comments on commit 16a96aa

Please sign in to comment.