Skip to content

Commit ff69d41

Browse files
committed
feat(cubejs-server-core): add contextToCubeStoreRouterId config option
1 parent 364d181 commit ff69d41

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

packages/cubejs-server-core/src/core/optionsValidate.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ const schemaOptions = Joi.object().keys({
7474
contextToAppId: Joi.func(),
7575
contextToRoles: Joi.func(),
7676
contextToOrchestratorId: Joi.func(),
77+
contextToCubeStoreRouterId: Joi.func(),
7778
contextToDataSourceId: Joi.func(),
7879
contextToApiScopes: Joi.func(),
7980
repositoryFactory: Joi.func(),

packages/cubejs-server-core/src/core/server.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import type {
5959
LoggerFn,
6060
DriverConfig,
6161
ScheduledRefreshTimeZonesFn,
62+
ContextToCubeStoreRouterIdFn,
6263
} from './types';
6364
import {
6465
ContextToOrchestratorIdFn,
@@ -135,7 +136,9 @@ export class CubejsServerCore {
135136

136137
protected compilerCache: LRUCache<string, CompilerApi>;
137138

138-
protected readonly contextToOrchestratorId: ContextToOrchestratorIdFn;
139+
protected readonly contextToOrchestratorId: ContextToOrchestratorIdFn | null;
140+
141+
protected readonly contextToCubeStoreRouterId: ContextToCubeStoreRouterIdFn;
139142

140143
protected readonly preAggregationsSchema: PreAggregationsSchemaFn;
141144

@@ -216,6 +219,7 @@ export class CubejsServerCore {
216219
}
217220

218221
this.contextToOrchestratorId = this.options.contextToOrchestratorId || (() => 'STANDALONE');
222+
this.contextToCubeStoreRouterId = this.options.contextToCubeStoreRouterId;
219223

220224
// proactively free up old cache values occasionally
221225
if (this.options.maxCompilerCacheKeepAlive) {

packages/cubejs-server-core/src/core/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export type DatabaseType =
123123
export type ContextToAppIdFn = (context: RequestContext) => string | Promise<string>;
124124
export type ContextToRolesFn = (context: RequestContext) => string[] | Promise<string[]>;
125125
export type ContextToOrchestratorIdFn = (context: RequestContext) => string | Promise<string>;
126+
export type ContextToCubeStoreRouterIdFn = (context: RequestContext) => string | Promise<string>;
126127

127128
export type OrchestratorOptionsFn = (context: RequestContext) => OrchestratorOptions | Promise<OrchestratorOptions>;
128129

@@ -190,6 +191,7 @@ export interface CreateOptions {
190191
contextToAppId?: ContextToAppIdFn;
191192
contextToRoles?: ContextToRolesFn;
192193
contextToOrchestratorId?: ContextToOrchestratorIdFn;
194+
contextToCubeStoreRouterId?: ContextToCubeStoreRouterIdFn;
193195
contextToApiScopes?: ContextToApiScopesFn;
194196
repositoryFactory?: (context: RequestContext) => SchemaFileRepository;
195197
checkAuth?: CheckAuthFn;

0 commit comments

Comments
 (0)