Skip to content

Commit 0dd2cd7

Browse files
committed
Use go-redis UniversalOptions/Client for simpler config
This implicitly adds support for redis sentinel HA configuration
1 parent 38e7252 commit 0dd2cd7

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

auth_server/authn/tokendb_redis.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
)
3131

3232
type RedisStoreConfig struct {
33-
ClientOptions *redis.Options `yaml:"redis_options,omitempty"`
33+
ClientOptions *redis.UniversalOptions `yaml:"redis_options,omitempty"`
3434
ClusterOptions *redis.ClusterOptions `yaml:"redis_cluster_options,omitempty"`
3535
TokenHashCost int `yaml:"token_hash_cost,omitempty"`
3636
}
@@ -51,7 +51,7 @@ func NewRedisTokenDB(options *RedisStoreConfig) (TokenDB, error) {
5151
}
5252
client = redis.NewClusterClient(options.ClusterOptions)
5353
} else {
54-
client = redis.NewClient(options.ClientOptions)
54+
client = redis.NewUniversalClient(options.ClientOptions)
5555
}
5656
tokenHashCost := options.TokenHashCost
5757
if tokenHashCost <= 0 {

examples/reference.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,13 @@ github_auth:
144144
# or Redis,
145145
redis_token_db:
146146
redis_options:
147-
# with a single instance,
148-
addr: localhost:6379
149-
redis_cluster_options:
150-
# or in the cluster mode.
151-
addrs: ["localhost:7000"]
147+
# with a single instance,
148+
addr: localhost:6379
149+
# or in the cluster mode.
150+
addrs: ["localhost:7000"]
151+
# or in the failover mode with redis sentinel.
152+
mastername: redis-ha
153+
sentineladdrs: ["redis-sentinel:26379"]
152154
# How long to wait when talking to GitHub servers. Optional.
153155
http_timeout: "10s"
154156
# How long to wait before revalidating the GitHub token. Optional.
@@ -221,9 +223,11 @@ gitlab_auth:
221223
redis_options:
222224
# with a single instance,
223225
addr: localhost:6379
224-
redis_cluster_options:
225226
# or in the cluster mode.
226227
addrs: ["localhost:7000"]
228+
# or in the failover mode with redis sentinel.
229+
mastername: redis-ha
230+
sentineladdrs: ["redis-sentinel:26379"]
227231
# How long to wait when talking to GitLab servers. Optional.
228232
http_timeout: "10s"
229233
# How long to wait before revalidating the Gitlab token. Optional.

0 commit comments

Comments
 (0)