Clean redlock test settings
This commit is contained in:
parent
57b4c08731
commit
25099ee28e
|
@ -13,13 +13,7 @@ async function getClient(
|
||||||
if (type === LockType.CUSTOM) {
|
if (type === LockType.CUSTOM) {
|
||||||
return newRedlock(opts)
|
return newRedlock(opts)
|
||||||
}
|
}
|
||||||
if (
|
|
||||||
env.isTest() &&
|
|
||||||
type !== LockType.TRY_ONCE &&
|
|
||||||
type !== LockType.AUTO_EXTEND
|
|
||||||
) {
|
|
||||||
return newRedlock(OPTIONS.TEST)
|
|
||||||
}
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case LockType.TRY_ONCE: {
|
case LockType.TRY_ONCE: {
|
||||||
return newRedlock(OPTIONS.TRY_ONCE)
|
return newRedlock(OPTIONS.TRY_ONCE)
|
||||||
|
@ -42,7 +36,7 @@ async function getClient(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const OPTIONS: Record<keyof typeof LockType | "TEST", Redlock.Options> = {
|
const OPTIONS: Record<keyof typeof LockType, Redlock.Options> = {
|
||||||
TRY_ONCE: {
|
TRY_ONCE: {
|
||||||
// immediately throws an error if the lock is already held
|
// immediately throws an error if the lock is already held
|
||||||
retryCount: 0,
|
retryCount: 0,
|
||||||
|
@ -50,11 +44,6 @@ const OPTIONS: Record<keyof typeof LockType | "TEST", Redlock.Options> = {
|
||||||
TRY_TWICE: {
|
TRY_TWICE: {
|
||||||
retryCount: 1,
|
retryCount: 1,
|
||||||
},
|
},
|
||||||
TEST: {
|
|
||||||
// higher retry count in unit tests
|
|
||||||
// due to high contention.
|
|
||||||
retryCount: 100,
|
|
||||||
},
|
|
||||||
DEFAULT: {
|
DEFAULT: {
|
||||||
// the expected clock drift; for more details
|
// the expected clock drift; for more details
|
||||||
// see http://redis.io/topics/distlock
|
// see http://redis.io/topics/distlock
|
||||||
|
|
Loading…
Reference in New Issue