diff --git a/backends/aerospike.go b/backends/aerospike.go index 03819b31..00468459 100644 --- a/backends/aerospike.go +++ b/backends/aerospike.go @@ -64,8 +64,8 @@ func NewAerospikeBackend(cfg config.Aerospike, metrics *metrics.Metrics) *Aerosp // Aerospike's connection idle deadline default is 55 seconds. If greater than zero, this // value will override - if cfg.ConnectionIdleTimeout > 0 { - clientPolicy.IdleTimeout = time.Duration(cfg.ConnectionIdleTimeout) * time.Second + if cfg.ConnIdleTimeoutSecs > 0 { + clientPolicy.IdleTimeout = time.Duration(cfg.ConnIdleTimeoutSecs) * time.Second } if len(cfg.Host) > 1 { diff --git a/backends/config/config.go b/backends/config/config.go index 7d9cf47d..8bcf20bd 100644 --- a/backends/config/config.go +++ b/backends/config/config.go @@ -84,8 +84,8 @@ func getMaxTTLSeconds(cfg config.Configuration) int { case config.BackendAerospike: // If both config.request_limits.max_ttl_seconds and config.backend.aerospike.default_ttl_seconds // were defined, the smallest value takes preference - if cfg.Backend.Aerospike.DefaultTTL > 0 && maxTTLSeconds > cfg.Backend.Aerospike.DefaultTTL { - maxTTLSeconds = cfg.Backend.Aerospike.DefaultTTL + if cfg.Backend.Aerospike.DefaultTTLSecs > 0 && maxTTLSeconds > cfg.Backend.Aerospike.DefaultTTLSecs { + maxTTLSeconds = cfg.Backend.Aerospike.DefaultTTLSecs } case config.BackendRedis: // If both config.request_limits.max_ttl_seconds and backend.redis.expiration diff --git a/backends/config/config_test.go b/backends/config/config_test.go index bab2f919..e058bb7a 100644 --- a/backends/config/config_test.go +++ b/backends/config/config_test.go @@ -233,7 +233,7 @@ func TestGetMaxTTLSeconds(t *testing.T) { Backend: config.Backend{ Type: config.BackendAerospike, Aerospike: config.Aerospike{ - DefaultTTL: 0, + DefaultTTLSecs: 0, }, }, RequestLimits: config.RequestLimits{ @@ -248,7 +248,7 @@ func TestGetMaxTTLSeconds(t *testing.T) { Backend: config.Backend{ Type: config.BackendAerospike, Aerospike: config.Aerospike{ - DefaultTTL: 100, + DefaultTTLSecs: 100, }, }, RequestLimits: config.RequestLimits{ @@ -263,7 +263,7 @@ func TestGetMaxTTLSeconds(t *testing.T) { Backend: config.Backend{ Type: config.BackendAerospike, Aerospike: config.Aerospike{ - DefaultTTL: 1, + DefaultTTLSecs: 1, }, }, RequestLimits: config.RequestLimits{ diff --git a/config/backends.go b/config/backends.go index a137d9b8..93718976 100644 --- a/config/backends.go +++ b/config/backends.go @@ -45,7 +45,7 @@ const ( ) type Aerospike struct { - DefaultTTL int `mapstructure:"default_ttl_seconds"` + DefaultTTLSecs int `mapstructure:"default_ttl_seconds"` Host string `mapstructure:"host"` Hosts []string `mapstructure:"hosts"` Port int `mapstructure:"port"` @@ -59,7 +59,7 @@ type Aerospike struct { // race conditions where the server closes the connection but the client still // tries to use it. If set to a value less than or equal to 0, Aerospike // Client's default value will be used which is 55 seconds. - ConnectionIdleTimeout int `mapstructure:"connection_idle_timeout_seconds"` + ConnIdleTimeoutSecs int `mapstructure:"connection_idle_timeout_seconds"` } func (cfg *Aerospike) validateAndLog() error { @@ -77,12 +77,12 @@ func (cfg *Aerospike) validateAndLog() error { log.Infof("config.backend.aerospike.namespace: %s", cfg.Namespace) log.Infof("config.backend.aerospike.user: %s", cfg.User) - if cfg.DefaultTTL > 0 { - log.Infof("config.backend.aerospike.default_ttl_seconds: %d. Note that this configuration option is being deprecated in favor of config.request_limits.max_ttl_seconds", cfg.DefaultTTL) + if cfg.DefaultTTLSecs > 0 { + log.Infof("config.backend.aerospike.default_ttl_seconds: %d. Note that this configuration option is being deprecated in favor of config.request_limits.max_ttl_seconds", cfg.DefaultTTLSecs) } - if cfg.ConnectionIdleTimeout > 0 { - log.Infof("config.backend.aerospike.connection_idle_timeout_seconds: %d.", cfg.ConnectionIdleTimeout) + if cfg.ConnIdleTimeoutSecs > 0 { + log.Infof("config.backend.aerospike.connection_idle_timeout_seconds: %d.", cfg.ConnIdleTimeoutSecs) } if cfg.MaxReadRetries < 2 { diff --git a/config/backends_test.go b/config/backends_test.go index 0646b5e9..fe8b4bf4 100644 --- a/config/backends_test.go +++ b/config/backends_test.go @@ -100,10 +100,10 @@ func TestAerospikeValidateAndLog(t *testing.T) { { desc: "both aerospike.host, aerospike.hosts and aerospike.default_ttl_seconds set", inCfg: Aerospike{ - Host: "foo.com", - Hosts: []string{"foo.com", "bat.com"}, - Port: 8888, - DefaultTTL: 3600, + Host: "foo.com", + Hosts: []string{"foo.com", "bat.com"}, + Port: 8888, + DefaultTTLSecs: 3600, }, hasError: false, logEntries: []logComponents{ @@ -189,9 +189,9 @@ func TestAerospikeValidateAndLog(t *testing.T) { { desc: "aerospike.connection_idle_timeout_seconds value found in config", inCfg: Aerospike{ - Host: "foo.com", - Port: 8888, - ConnectionIdleTimeout: 1, + Host: "foo.com", + Port: 8888, + ConnIdleTimeoutSecs: 1, }, hasError: false, logEntries: []logComponents{ diff --git a/config/config_test.go b/config/config_test.go index d8b9c77f..28578b68 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -1245,14 +1245,15 @@ func getExpectedFullConfigForTestFile() Configuration { Backend: Backend{ Type: BackendMemory, Aerospike: Aerospike{ - DefaultTTL: 3600, - Host: "aerospike.prebid.com", - Hosts: []string{"aerospike2.prebid.com", "aerospike3.prebid.com"}, - Port: 3000, - Namespace: "whatever", - User: "foo", - Password: "bar", - MaxReadRetries: 2, + DefaultTTLSecs: 3600, + Host: "aerospike.prebid.com", + Hosts: []string{"aerospike2.prebid.com", "aerospike3.prebid.com"}, + Port: 3000, + Namespace: "whatever", + User: "foo", + Password: "bar", + MaxReadRetries: 2, + ConnIdleTimeoutSecs: 2, }, Cassandra: Cassandra{ Hosts: "127.0.0.1", diff --git a/config/configtest/sample_full_config.yaml b/config/configtest/sample_full_config.yaml index 0f1454ee..6c298d59 100644 --- a/config/configtest/sample_full_config.yaml +++ b/config/configtest/sample_full_config.yaml @@ -21,6 +21,7 @@ backend: namespace: "whatever" user: "foo" password: "bar" + connection_idle_timeout_seconds: 2 cassandra: hosts: "127.0.0.1" keyspace: "prebid"