Make expiration a flag

This commit is contained in:
Jonathan Lange
2016-07-04 14:20:14 +01:00
parent 7dd2c6371e
commit 848574eced
2 changed files with 14 additions and 12 deletions

View File

@@ -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

View File

@@ -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")