Skip to content

Commit a83cba3

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

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ import type {
4646
DriverContext,
4747
LoggerFn,
4848
DriverConfig,
49+
ContextToCubeStoreRouterIdFn,
4950
} from './types';
51+
5052
import { ContextToOrchestratorIdFn, ContextAcceptanceResult, ContextAcceptanceResultHttp, ContextAcceptanceResultWs, ContextAcceptor } from './types';
5153

5254
const { version } = require('../../../package.json');
@@ -115,7 +117,9 @@ export class CubejsServerCore {
115117

116118
protected compilerCache: LRUCache<string, CompilerApi>;
117119

118-
protected readonly contextToOrchestratorId: ContextToOrchestratorIdFn;
120+
protected readonly contextToOrchestratorId: ContextToOrchestratorIdFn | null;
121+
122+
protected readonly contextToCubeStoreRouterId: ContextToCubeStoreRouterIdFn;
119123

120124
protected readonly preAggregationsSchema: PreAggregationsSchemaFn;
121125

@@ -192,6 +196,7 @@ export class CubejsServerCore {
192196
}
193197

194198
this.contextToOrchestratorId = this.options.contextToOrchestratorId || (() => 'STANDALONE');
199+
this.contextToCubeStoreRouterId = this.options.contextToCubeStoreRouterId;
195200

196201
// proactively free up old cache values occasionally
197202
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)