Plumb through an option for compression

This commit is contained in:
Jonathan Lange
2016-07-15 11:24:36 +01:00
parent 2bfd6d7eb7
commit 60e14c1dc2
3 changed files with 28 additions and 22 deletions
+6 -5
View File
@@ -58,11 +58,12 @@ type MemcacheClient struct {
// MemcacheConfig defines how a MemcacheClient should be constructed.
type MemcacheConfig struct {
Host string
Service string
Timeout time.Duration
UpdateInterval time.Duration
Expiration time.Duration
Host string
Service string
Timeout time.Duration
UpdateInterval time.Duration
Expiration time.Duration
CompressionLevel int
}
// NewMemcacheClient creates a new MemcacheClient that gets its server list
+9 -7
View File
@@ -81,7 +81,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, memcachedExpiration, window time.Duration, createTables bool) (app.Collector, error) {
func collectorFactory(userIDer multitenant.UserIDer, collectorURL, s3URL, natsHostname, memcachedHostname string, memcachedTimeout time.Duration, memcachedService string, memcachedExpiration time.Duration, memcachedCompressionLevel int, window time.Duration, createTables bool) (app.Collector, error) {
if collectorURL == "local" {
return app.NewCollector(window), nil
}
@@ -114,11 +114,12 @@ func collectorFactory(userIDer multitenant.UserIDer, collectorURL, s3URL, natsHo
if memcachedHostname != "" {
memcacheClient = multitenant.NewMemcacheClient(
multitenant.MemcacheConfig{
Host: memcachedHostname,
Timeout: memcachedTimeout,
Expiration: memcachedExpiration,
UpdateInterval: memcacheUpdateInterval,
Service: memcachedService,
Host: memcachedHostname,
Timeout: memcachedTimeout,
Expiration: memcachedExpiration,
UpdateInterval: memcacheUpdateInterval,
Service: memcachedService,
CompressionLevel: memcachedCompressionLevel,
},
)
}
@@ -214,7 +215,8 @@ func appMain(flags appFlags) {
collector, err := collectorFactory(
userIDer, flags.collectorURL, flags.s3URL, flags.natsHostname, flags.memcachedHostname,
flags.memcachedTimeout, flags.memcachedService, flags.memcachedExpiration, flags.window, flags.awsCreateTables)
flags.memcachedTimeout, flags.memcachedService, flags.memcachedExpiration, flags.memcachedCompressionLevel,
flags.window, flags.awsCreateTables)
if err != nil {
log.Fatalf("Error creating collector: %v", err)
return
+13 -10
View File
@@ -1,6 +1,7 @@
package main
import (
"compress/gzip"
"flag"
"fmt"
"net"
@@ -100,16 +101,17 @@ type appFlags struct {
containerName string
dockerEndpoint string
collectorURL string
s3URL string
controlRouterURL string
pipeRouterURL string
natsHostname string
memcachedHostname string
memcachedTimeout time.Duration
memcachedService string
memcachedExpiration time.Duration
userIDHeader string
collectorURL string
s3URL string
controlRouterURL string
pipeRouterURL string
natsHostname string
memcachedHostname string
memcachedTimeout time.Duration
memcachedService string
memcachedExpiration time.Duration
memcachedCompressionLevel int
userIDHeader string
awsCreateTables bool
consulInf string
@@ -195,6 +197,7 @@ func main() {
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", 2*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.IntVar(&flags.app.memcachedCompressionLevel, "app.memcached.compression", gzip.DefaultCompression, "How much to compress reports stored in memcached.")
flag.StringVar(&flags.app.userIDHeader, "app.userid.header", "", "HTTP header to use as userid")
flag.BoolVar(&flags.app.awsCreateTables, "app.aws.create.tables", false, "Create the tables in DynamoDB")