@@ -142,6 +142,9 @@ describe("defineConfig", function () {
|
||||
},
|
||||
"storeCors": "http://localhost:8000",
|
||||
},
|
||||
"redisOptions": {
|
||||
"retryStrategy": [Function],
|
||||
},
|
||||
},
|
||||
}
|
||||
`)
|
||||
@@ -298,6 +301,9 @@ describe("defineConfig", function () {
|
||||
},
|
||||
"storeCors": "http://localhost:8000",
|
||||
},
|
||||
"redisOptions": {
|
||||
"retryStrategy": [Function],
|
||||
},
|
||||
},
|
||||
}
|
||||
`)
|
||||
@@ -462,6 +468,9 @@ describe("defineConfig", function () {
|
||||
},
|
||||
"storeCors": "http://localhost:8000",
|
||||
},
|
||||
"redisOptions": {
|
||||
"retryStrategy": [Function],
|
||||
},
|
||||
},
|
||||
}
|
||||
`)
|
||||
@@ -627,6 +636,9 @@ describe("defineConfig", function () {
|
||||
},
|
||||
"storeCors": "http://localhost:8000",
|
||||
},
|
||||
"redisOptions": {
|
||||
"retryStrategy": [Function],
|
||||
},
|
||||
},
|
||||
}
|
||||
`)
|
||||
@@ -780,6 +792,9 @@ describe("defineConfig", function () {
|
||||
},
|
||||
"storeCors": "http://localhost:8000",
|
||||
},
|
||||
"redisOptions": {
|
||||
"retryStrategy": [Function],
|
||||
},
|
||||
},
|
||||
}
|
||||
`)
|
||||
@@ -933,6 +948,9 @@ describe("defineConfig", function () {
|
||||
},
|
||||
"storeCors": "http://localhost:8000",
|
||||
},
|
||||
"redisOptions": {
|
||||
"retryStrategy": [Function],
|
||||
},
|
||||
},
|
||||
}
|
||||
`)
|
||||
|
||||
@@ -74,7 +74,8 @@ type Config = Partial<
|
||||
* to override configuration as needed.
|
||||
*/
|
||||
export function defineConfig(config: Config = {}): ConfigModule {
|
||||
const { http, ...restOfProjectConfig } = config.projectConfig || {}
|
||||
const { http, redisOptions, ...restOfProjectConfig } =
|
||||
config.projectConfig || {}
|
||||
|
||||
/**
|
||||
* The defaults to use for the project config. They are shallow merged
|
||||
@@ -93,6 +94,23 @@ export function defineConfig(config: Config = {}): ConfigModule {
|
||||
},
|
||||
...http,
|
||||
},
|
||||
redisOptions: {
|
||||
retryStrategy(retries) {
|
||||
/**
|
||||
* Exponentially increase delay with every retry
|
||||
* attempt. Max to 4s
|
||||
*/
|
||||
const delay = Math.min(Math.pow(2, retries) * 50, 4000)
|
||||
|
||||
/**
|
||||
* Add a random jitter to not choke the server when multiple
|
||||
* clients are retrying at the same time
|
||||
*/
|
||||
const jitter = Math.floor(Math.random() * 200)
|
||||
return delay + jitter
|
||||
},
|
||||
...redisOptions,
|
||||
},
|
||||
...restOfProjectConfig,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user