mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2026-10-18 04:41:19 +02:00
adding IdleTimeout with the redis-connection-idle-timeout flag, to ke… (#1691)
* adding IdleTimeout with the redis-connection-idle-timeout flag, to keep redis connections in valid state, when Redis option is set * docs update - add redis idle timeout configurations * changelog update for #1691 fix
This commit is contained in:
@@ -143,7 +143,7 @@ func NewFlagSet() *pflag.FlagSet {
|
||||
flagSet.StringSlice("redis-sentinel-connection-urls", []string{}, "List of Redis sentinel connection URLs (eg redis://HOST[:PORT]). Used in conjunction with --redis-use-sentinel")
|
||||
flagSet.Bool("redis-use-cluster", false, "Connect to redis cluster. Must set --redis-cluster-connection-urls to use this feature")
|
||||
flagSet.StringSlice("redis-cluster-connection-urls", []string{}, "List of Redis cluster connection URLs (eg redis://HOST[:PORT]). Used in conjunction with --redis-use-cluster")
|
||||
|
||||
flagSet.Int("redis-connection-idle-timeout", 0, "Redis connection idle timeout seconds, if Redis timeout option is non-zero, the --redis-connection-idle-timeout must be less then Redis timeout option")
|
||||
flagSet.String("signature-key", "", "GAP-Signature request signature key (algorithm:secretkey)")
|
||||
flagSet.Bool("gcp-healthchecks", false, "Enable GCP/GKE healthcheck endpoints")
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ type RedisStoreOptions struct {
|
||||
ClusterConnectionURLs []string `flag:"redis-cluster-connection-urls" cfg:"redis_cluster_connection_urls"`
|
||||
CAPath string `flag:"redis-ca-path" cfg:"redis_ca_path"`
|
||||
InsecureSkipTLSVerify bool `flag:"redis-insecure-skip-tls-verify" cfg:"redis_insecure_skip_tls_verify"`
|
||||
IdleTimeout int `flag:"redis-connection-idle-timeout" cfg:"redis_connection_idle_timeout"`
|
||||
}
|
||||
|
||||
func sessionOptionsDefaults() SessionOptions {
|
||||
|
||||
@@ -104,6 +104,7 @@ func buildSentinelClient(opts options.RedisStoreOptions) (Client, error) {
|
||||
SentinelPassword: opts.SentinelPassword,
|
||||
Password: opts.Password,
|
||||
TLSConfig: opt.TLSConfig,
|
||||
IdleTimeout: time.Duration(opts.IdleTimeout) * time.Second,
|
||||
})
|
||||
return newClient(client), nil
|
||||
}
|
||||
@@ -120,9 +121,10 @@ func buildClusterClient(opts options.RedisStoreOptions) (Client, error) {
|
||||
}
|
||||
|
||||
client := redis.NewClusterClient(&redis.ClusterOptions{
|
||||
Addrs: addrs,
|
||||
Password: opts.Password,
|
||||
TLSConfig: opt.TLSConfig,
|
||||
Addrs: addrs,
|
||||
Password: opts.Password,
|
||||
TLSConfig: opt.TLSConfig,
|
||||
IdleTimeout: time.Duration(opts.IdleTimeout) * time.Second,
|
||||
})
|
||||
return newClusterClient(client), nil
|
||||
}
|
||||
@@ -143,6 +145,8 @@ func buildStandaloneClient(opts options.RedisStoreOptions) (Client, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
opt.IdleTimeout = time.Duration(opts.IdleTimeout) * time.Second
|
||||
|
||||
client := redis.NewClient(opt)
|
||||
return newClient(client), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user