Skip to content

Commit

Permalink
Mansi's review
Browse files Browse the repository at this point in the history
  • Loading branch information
guscarreon committed Nov 8, 2022
1 parent ffa103b commit 4ee257d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
27 changes: 16 additions & 11 deletions config/backends.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,21 @@ const (
)

type Aerospike struct {
DefaultTTL int `mapstructure:"default_ttl_seconds"`
Host string `mapstructure:"host"`
Hosts []string `mapstructure:"hosts"`
Port int `mapstructure:"port"`
Namespace string `mapstructure:"namespace"`
User string `mapstructure:"user"`
Password string `mapstructure:"password"`
MaxReadRetries int `mapstructure:"max_read_retries"`
MaxWriteRetries int `mapstructure:"max_write_retries"`
ConnectionIdleTimeout int `mapstructure:"connection_idle_timeout"`
DefaultTTL int `mapstructure:"default_ttl_seconds"`
Host string `mapstructure:"host"`
Hosts []string `mapstructure:"hosts"`
Port int `mapstructure:"port"`
Namespace string `mapstructure:"namespace"`
User string `mapstructure:"user"`
Password string `mapstructure:"password"`
MaxReadRetries int `mapstructure:"max_read_retries"`
MaxWriteRetries int `mapstructure:"max_write_retries"`
// Please set this to a value lower than the `proto-fd-idle-ms` (converted
// to seconds) value set in your Aerospike Server. This is to avoid having
// 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"`
}

func (cfg *Aerospike) validateAndLog() error {
Expand All @@ -77,7 +82,7 @@ func (cfg *Aerospike) validateAndLog() error {
}

if cfg.ConnectionIdleTimeout > 0 {
log.Infof("config.backend.aerospike.connection_idle_timeout: %d. Will substitute Aerospike's default 55 seconds.", cfg.ConnectionIdleTimeout)
log.Infof("config.backend.aerospike.connection_idle_timeout_seconds: %d.", cfg.ConnectionIdleTimeout)
}

if cfg.MaxReadRetries < 2 {
Expand Down
4 changes: 2 additions & 2 deletions config/backends_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func TestAerospikeValidateAndLog(t *testing.T) {
},
},
{
desc: "aerospike.connection_idle_timeout value found in config",
desc: "aerospike.connection_idle_timeout_seconds value found in config",
inCfg: Aerospike{
Host: "foo.com",
Port: 8888,
Expand All @@ -200,7 +200,7 @@ func TestAerospikeValidateAndLog(t *testing.T) {
{msg: "config.backend.aerospike.port: 8888", lvl: logrus.InfoLevel},
{msg: "config.backend.aerospike.namespace: ", lvl: logrus.InfoLevel},
{msg: "config.backend.aerospike.user: ", lvl: logrus.InfoLevel},
{msg: "config.backend.aerospike.connection_idle_timeout: 1. Will substitute Aerospike's default 55 seconds.", lvl: logrus.InfoLevel},
{msg: "config.backend.aerospike.connection_idle_timeout_seconds: 1.", lvl: logrus.InfoLevel},
{msg: "config.backend.aerospike.max_read_retries value will default to 2", lvl: logrus.InfoLevel},
},
},
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func setConfigDefaults(v *viper.Viper) {
v.SetDefault("backend.aerospike.default_ttl_seconds", 0)
v.SetDefault("backend.aerospike.max_read_retries", 2)
v.SetDefault("backend.aerospike.max_write_retries", 0)
v.SetDefault("backend.aerospike.connection_idle_timeout", 0)
v.SetDefault("backend.aerospike.connection_idle_timeout_seconds", 0)
v.SetDefault("backend.cassandra.hosts", "")
v.SetDefault("backend.cassandra.keyspace", "")
v.SetDefault("backend.cassandra.default_ttl_seconds", utils.CASSANDRA_DEFAULT_TTL_SECONDS)
Expand Down

0 comments on commit 4ee257d

Please sign in to comment.