From 848574ecedb35874ae7a0a8c61313b9807d7c25b Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Mon, 4 Jul 2016 14:20:14 +0100 Subject: [PATCH] Make expiration a flag --- prog/app.go | 6 +++--- prog/main.go | 20 +++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/prog/app.go b/prog/app.go index eaae140f6..f786a3883 100644 --- a/prog/app.go +++ b/prog/app.go @@ -80,7 +80,7 @@ func awsConfigFromURL(url *url.URL) (*aws.Config, error) { return config, nil } -func collectorFactory(userIDer multitenant.UserIDer, collectorURL, s3URL, natsHostname, memcachedHostname string, memcachedTimeout time.Duration, memcachedService string, window time.Duration, createTables bool) (app.Collector, error) { +func collectorFactory(userIDer multitenant.UserIDer, collectorURL, s3URL, natsHostname, memcachedHostname string, memcachedTimeout time.Duration, memcachedService string, memcachedExpiration, window time.Duration, createTables bool) (app.Collector, error) { if collectorURL == "local" { return app.NewCollector(window), nil } @@ -112,7 +112,7 @@ func collectorFactory(userIDer multitenant.UserIDer, collectorURL, s3URL, natsHo multitenant.MemcacheConfig{ Host: memcachedHostname, Timeout: memcachedTimeout, - Expiration: window, + Expiration: memcachedExpiration, UpdateInterval: memcacheUpdateInterval, Service: memcachedService, }, @@ -210,7 +210,7 @@ func appMain(flags appFlags) { collector, err := collectorFactory( userIDer, flags.collectorURL, flags.s3URL, flags.natsHostname, flags.memcachedHostname, - flags.memcachedTimeout, flags.memcachedService, flags.window, flags.awsCreateTables) + flags.memcachedTimeout, flags.memcachedService, flags.memcachedExpiration, flags.window, flags.awsCreateTables) if err != nil { log.Fatalf("Error creating collector: %v", err) return diff --git a/prog/main.go b/prog/main.go index f1c9da818..b989ad122 100644 --- a/prog/main.go +++ b/prog/main.go @@ -99,15 +99,16 @@ type appFlags struct { containerName string dockerEndpoint string - collectorURL string - s3URL string - controlRouterURL string - pipeRouterURL string - natsHostname string - memcachedHostname string - memcachedTimeout time.Duration - memcachedService string - userIDHeader string + collectorURL string + s3URL string + controlRouterURL string + pipeRouterURL string + natsHostname string + memcachedHostname string + memcachedTimeout time.Duration + memcachedService string + memcachedExpiration time.Duration + userIDHeader string awsCreateTables bool consulInf string @@ -190,6 +191,7 @@ func main() { flag.StringVar(&flags.app.natsHostname, "app.nats", "", "Hostname for NATS service to use for shortcut reports. If empty, shortcut reporting will be disabled.") flag.StringVar(&flags.app.memcachedHostname, "app.memcached.hostname", "", "Hostname for memcached service to use when caching reports. If empty, no memcached will be used.") flag.DurationVar(&flags.app.memcachedTimeout, "app.memcached.timeout", 100*time.Millisecond, "Maximum time to wait before giving up on memcached requests.") + flag.DurationVar(&flags.app.memcachedExpiration, "app.memcached.expiration", 15*time.Second, "How long reports stay in the memcache.") flag.StringVar(&flags.app.memcachedService, "app.memcached.service", "memcached", "SRV service used to discover memcache servers.") flag.StringVar(&flags.app.userIDHeader, "app.userid.header", "", "HTTP header to use as userid")