Skip to content

Commit 6d0096e

Browse files
committed
feat: CUBEJS_SCHEDULED_REFRESH_TIMER env variable
1 parent bf141c8 commit 6d0096e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

docs/Cube.js-Backend/@cubejs-backend-server-core.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ CubejsServerCore.create({
334334
### scheduledRefreshTimer
335335

336336
Pass `true` to enable default every 5 second scheduled refresh timer with default querying options.
337+
Can be also set using `CUBEJS_SCHEDULED_REFRESH_TIMER` env variable.
337338
Each timer invocation will call `runScheduledRefresh()` method as in:
338339

339340
```javascript

packages/cubejs-server-core/core/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,14 @@ class CubejsServerCore {
222222
setInterval(() => this.compilerCache.prune(), options.maxCompilerCacheKeepAlive);
223223
}
224224

225-
if (options.scheduledRefreshTimer) {
225+
this.scheduledRefreshTimer = options.scheduledRefreshTimer || process.env.CUBEJS_SCHEDULED_REFRESH_TIMER;
226+
227+
if (this.scheduledRefreshTimer) {
226228
setInterval(
227229
() => this.runScheduledRefresh(),
228-
typeof options.scheduledRefreshTimer === 'number' ? (options.scheduledRefreshTimer * 1000) : 5000
230+
typeof this.scheduledRefreshTimer === 'number' || this.scheduledRefreshTimer.match(/^\d+$/) ?
231+
(this.scheduledRefreshTimer * 1000) :
232+
5000
229233
);
230234
}
231235

0 commit comments

Comments
 (0)