Skip to content

Commit

Permalink
Renamed to DefaultTTLSecs and ConnIdleTimeoutSecs
Browse files Browse the repository at this point in the history
  • Loading branch information
guscarreon committed Nov 9, 2022
1 parent 4ee257d commit 97b5006
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 28 deletions.
4 changes: 2 additions & 2 deletions backends/aerospike.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions backends/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions backends/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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{
Expand All @@ -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{
Expand Down
12 changes: 6 additions & 6 deletions config/backends.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions config/backends_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down
17 changes: 9 additions & 8 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions config/configtest/sample_full_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ backend:
namespace: "whatever"
user: "foo"
password: "bar"
connection_idle_timeout_seconds: 2
cassandra:
hosts: "127.0.0.1"
keyspace: "prebid"
Expand Down

0 comments on commit 97b5006

Please sign in to comment.