mirror of
https://github.com/gomods/athens
synced 2026-02-03 08:40:31 +00:00
read redis lock options from config to support custom TTL & timeout (#1791)
* read redis lock options from config to support custom TTL & timeout * fix test * fix typo * downgrade to bsm/redislock@v0.7.2 to prevent usage of beta go-redis version * revert test changes * return error for invalid lock config * update config parsing test * udpate docs to include redis lock config * fix test * set default max retries to 10 * reduce default redis lock timeout to 15s * update default TTL to 15mins Co-authored-by: Manu Gupta <manugupt1@gmail.com>
This commit is contained in:
@@ -437,6 +437,24 @@ You can also optionally specify a password to connect to the redis server with
|
||||
# Env override: ATHENS_REDIS_PASSWORD
|
||||
Password = ""
|
||||
|
||||
##### Customizing lock configurations:
|
||||
If you would like to customize the distributed lock options then you can optionally override the default lock config to better suit your use-case:
|
||||
|
||||
[SingleFlight.Redis]
|
||||
...
|
||||
[SingleFlight.Redis.LockConfig]
|
||||
# TTL for the lock in seconds. Defaults to 900 seconds (15 minutes).
|
||||
# Env override: ATHENS_REDIS_LOCK_TTL
|
||||
TTL = 900
|
||||
# Timeout for acquiring the lock in seconds. Defaults to 15 seconds.
|
||||
# Env override: ATHENS_REDIS_LOCK_TIMEOUT
|
||||
Timeout = 15
|
||||
# Max retries while acquiring the lock. Defaults to 10.
|
||||
# Env override: ATHENS_REDIS_LOCK_MAX_RETRIES
|
||||
MaxRetries = 10
|
||||
|
||||
Customizations may be required in some cases for eg, you can set a higher TTL if it usually takes longer than 5 mins to fetch the modules in your case.
|
||||
|
||||
#### Connecting to redis via redis sentinel
|
||||
|
||||
**NOTE**: redis-sentinel requires a working knowledge of redis and is not recommended for
|
||||
@@ -472,3 +490,5 @@ Optionally, like `redis`, you can also specify a password to connect to the `red
|
||||
# SentinelPassword is an optional password for authenticating with
|
||||
# redis sentinel
|
||||
SentinelPassword = "sekret"
|
||||
|
||||
Distributed lock options can be customised for redis sentinal as well, in a similar manner as described above for redis.
|
||||
Reference in New Issue
Block a user