summaryrefslogtreecommitdiff
path: root/internal/configuration/schema
diff options
context:
space:
mode:
authorAmir Zarrinkafsh <nightah@me.com>2024-11-02 07:40:40 +1100
committerGitHub <noreply@github.com>2024-11-01 20:40:40 +0000
commit7584aaccb9c4a88e352bbcdf77e79a1d27a57a70 (patch)
treed602fecfba535e756fa11cc364489f7bcf992452 /internal/configuration/schema
parentac5cf4345e3ccf88c5862199131a7a6bd0f193f4 (diff)
fix(session): add connection timeout and retry options to redis (#8146)
* fix(session): add connection timeout and retry options to redis * docs: add new redis options to docs Signed-off-by: Amir Zarrinkafsh <nightah@me.com>
Diffstat (limited to 'internal/configuration/schema')
-rw-r--r--internal/configuration/schema/keys.go2
-rw-r--r--internal/configuration/schema/session.go22
2 files changed, 16 insertions, 8 deletions
diff --git a/internal/configuration/schema/keys.go b/internal/configuration/schema/keys.go
index 143d792ce..bc3b07460 100644
--- a/internal/configuration/schema/keys.go
+++ b/internal/configuration/schema/keys.go
@@ -193,6 +193,8 @@ var Keys = []string{
"session.cookies[]",
"session.redis.host",
"session.redis.port",
+ "session.redis.timeout",
+ "session.redis.max_retries",
"session.redis.username",
"session.redis.password",
"session.redis.database_index",
diff --git a/internal/configuration/schema/session.go b/internal/configuration/schema/session.go
index c2fc3f35b..2a01ed40e 100644
--- a/internal/configuration/schema/session.go
+++ b/internal/configuration/schema/session.go
@@ -43,14 +43,16 @@ type SessionCookie struct {
// SessionRedis represents the configuration related to redis session store.
type SessionRedis struct {
- Host string `koanf:"host" json:"host" jsonschema:"title=Host" jsonschema_description:"The redis server host."`
- Port int `koanf:"port" json:"port" jsonschema:"default=6379,title=Host" jsonschema_description:"The redis server port."`
- Username string `koanf:"username" json:"username" jsonschema:"title=Username" jsonschema_description:"The redis username."`
- Password string `koanf:"password" json:"password" jsonschema:"title=Password" jsonschema_description:"The redis password."`
- DatabaseIndex int `koanf:"database_index" json:"database_index" jsonschema:"default=0,title=Database Index" jsonschema_description:"The redis database index."`
- MaximumActiveConnections int `koanf:"maximum_active_connections" json:"maximum_active_connections" jsonschema:"default=8,title=Maximum Active Connections" jsonschema_description:"The maximum connections that can be made to redis at one time."`
- MinimumIdleConnections int `koanf:"minimum_idle_connections" json:"minimum_idle_connections" jsonschema:"title=Minimum Idle Connections" jsonschema_description:"The minimum idle connections that should be open to redis."`
- TLS *TLS `koanf:"tls" json:"tls"`
+ Host string `koanf:"host" json:"host" jsonschema:"title=Host" jsonschema_description:"The redis server host."`
+ Port int `koanf:"port" json:"port" jsonschema:"default=6379,title=Host" jsonschema_description:"The redis server port."`
+ Timeout time.Duration `koanf:"timeout" json:"timeout" jsonschema:"default=5 seconds,title=Timeout" jsonschema_description:"The Redis server connection timeout."`
+ MaxRetries int `koanf:"max_retries" json:"max_retries" jsonschema:"default=3,title=Maximum Retries" jsonschema_description:"The maximum number of retries on a failed command."`
+ Username string `koanf:"username" json:"username" jsonschema:"title=Username" jsonschema_description:"The redis username."`
+ Password string `koanf:"password" json:"password" jsonschema:"title=Password" jsonschema_description:"The redis password."`
+ DatabaseIndex int `koanf:"database_index" json:"database_index" jsonschema:"default=0,title=Database Index" jsonschema_description:"The redis database index."`
+ MaximumActiveConnections int `koanf:"maximum_active_connections" json:"maximum_active_connections" jsonschema:"default=8,title=Maximum Active Connections" jsonschema_description:"The maximum connections that can be made to redis at one time."`
+ MinimumIdleConnections int `koanf:"minimum_idle_connections" json:"minimum_idle_connections" jsonschema:"title=Minimum Idle Connections" jsonschema_description:"The minimum idle connections that should be open to redis."`
+ TLS *TLS `koanf:"tls" json:"tls"`
HighAvailability *SessionRedisHighAvailability `koanf:"high_availability" json:"high_availability"`
}
@@ -86,6 +88,8 @@ var DefaultSessionConfiguration = Session{
// DefaultRedisConfiguration is the default redis configuration.
var DefaultRedisConfiguration = SessionRedis{
Port: 6379,
+ Timeout: time.Second * 5,
+ MaxRetries: 0,
MaximumActiveConnections: 8,
TLS: &TLS{
MinimumVersion: TLSVersion{Value: tls.VersionTLS12},
@@ -95,6 +99,8 @@ var DefaultRedisConfiguration = SessionRedis{
// DefaultRedisHighAvailabilityConfiguration is the default redis configuration.
var DefaultRedisHighAvailabilityConfiguration = SessionRedis{
Port: 26379,
+ Timeout: time.Second * 5,
+ MaxRetries: 0,
MaximumActiveConnections: 8,
TLS: &TLS{
MinimumVersion: TLSVersion{Value: tls.VersionTLS12},