Skip to content

Commit ebcd390

Browse files
committed
feat(cubejs-server-core): add contextToCubeStoreRouterId config option
1 parent 86e49d7 commit ebcd390

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
@@ -46,6 +46,7 @@ import type {
4646
DriverContext,
4747
LoggerFn,
4848
DriverConfig,
49+
ContextToCubeStoreRouterIdFn,
4950
} from './types';
5051
import { ContextToOrchestratorIdFn, ContextAcceptanceResult, ContextAcceptanceResultHttp, ContextAcceptanceResultWs, ContextAcceptor } from './types';
5152

@@ -115,7 +116,9 @@ export class CubejsServerCore {
115116

116117
protected compilerCache: LRUCache<string, CompilerApi>;
117118

118-
protected readonly contextToOrchestratorId: ContextToOrchestratorIdFn;
119+
protected readonly contextToOrchestratorId: ContextToOrchestratorIdFn | null;
120+
121+
protected readonly contextToCubeStoreRouterId: ContextToCubeStoreRouterIdFn;
119122

120123
protected readonly preAggregationsSchema: PreAggregationsSchemaFn;
121124

@@ -192,6 +195,7 @@ export class CubejsServerCore {
192195
}
193196

194197
this.contextToOrchestratorId = this.options.contextToOrchestratorId || (() => 'STANDALONE');
198+
this.contextToCubeStoreRouterId = this.options.contextToCubeStoreRouterId;
195199

196200
// proactively free up old cache values occasionally
197201
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
@@ -122,6 +122,7 @@ export type DatabaseType =
122122
export type ContextToAppIdFn = (context: RequestContext) => string | Promise<string>;
123123
export type ContextToRolesFn = (context: RequestContext) => string[] | Promise<string[]>;
124124
export type ContextToOrchestratorIdFn = (context: RequestContext) => string | Promise<string>;
125+
export type ContextToCubeStoreRouterIdFn = (context: RequestContext) => string | Promise<string>;
125126

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

@@ -179,6 +180,7 @@ export interface CreateOptions {
179180
contextToAppId?: ContextToAppIdFn;
180181
contextToRoles?: ContextToRolesFn;
181182
contextToOrchestratorId?: ContextToOrchestratorIdFn;
183+
contextToCubeStoreRouterId?: ContextToCubeStoreRouterIdFn;
182184
contextToApiScopes?: ContextToApiScopesFn;
183185
repositoryFactory?: (context: RequestContext) => SchemaFileRepository;
184186
checkAuth?: CheckAuthFn;

0 commit comments

Comments
 (0)