diff --git a/packages/cubejs-backend-native/python/cube/src/__init__.py b/packages/cubejs-backend-native/python/cube/src/__init__.py index b91f90fc0fab5..d18cc154fe69c 100644 --- a/packages/cubejs-backend-native/python/cube/src/__init__.py +++ b/packages/cubejs-backend-native/python/cube/src/__init__.py @@ -62,6 +62,7 @@ class Configuration: logger: Callable context_to_app_id: Union[str, Callable[[RequestContext], str]] context_to_orchestrator_id: Union[str, Callable[[RequestContext], str]] + context_to_cube_store_router_id: Union[str, Callable[[RequestContext], str]] driver_factory: Callable[[RequestContext], Dict] external_driver_factory: Callable[[RequestContext], Dict] db_type: Union[str, Callable[[RequestContext], str]] @@ -108,6 +109,7 @@ def __init__(self): self.logger = None self.context_to_app_id = None self.context_to_orchestrator_id = None + self.context_to_cube_store_router_id = None self.driver_factory = None self.external_driver_factory = None self.db_type = None diff --git a/packages/cubejs-backend-native/src/python/cube_config.rs b/packages/cubejs-backend-native/src/python/cube_config.rs index 783600bf5905c..0b718112babcc 100644 --- a/packages/cubejs-backend-native/src/python/cube_config.rs +++ b/packages/cubejs-backend-native/src/python/cube_config.rs @@ -47,6 +47,7 @@ impl CubeConfigPy { "logger", "context_to_app_id", "context_to_orchestrator_id", + "context_to_cube_store_router_id", "driver_factory", "external_driver_factory", "db_type", diff --git a/packages/cubejs-server-core/src/core/optionsValidate.ts b/packages/cubejs-server-core/src/core/optionsValidate.ts index 157d2acb84cd9..161186938e16f 100644 --- a/packages/cubejs-server-core/src/core/optionsValidate.ts +++ b/packages/cubejs-server-core/src/core/optionsValidate.ts @@ -74,6 +74,7 @@ const schemaOptions = Joi.object().keys({ contextToAppId: Joi.func(), contextToRoles: Joi.func(), contextToOrchestratorId: Joi.func(), + contextToCubeStoreRouterId: Joi.func(), contextToDataSourceId: Joi.func(), contextToApiScopes: Joi.func(), repositoryFactory: Joi.func(), diff --git a/packages/cubejs-server-core/src/core/server.ts b/packages/cubejs-server-core/src/core/server.ts index 673096142a720..bbc1883bcbb82 100644 --- a/packages/cubejs-server-core/src/core/server.ts +++ b/packages/cubejs-server-core/src/core/server.ts @@ -46,7 +46,9 @@ import type { DriverContext, LoggerFn, DriverConfig, + ContextToCubeStoreRouterIdFn, } from './types'; + import { ContextToOrchestratorIdFn, ContextAcceptanceResult, ContextAcceptanceResultHttp, ContextAcceptanceResultWs, ContextAcceptor } from './types'; const { version } = require('../../../package.json'); @@ -117,6 +119,8 @@ export class CubejsServerCore { protected readonly contextToOrchestratorId: ContextToOrchestratorIdFn; + protected readonly contextToCubeStoreRouterId: ContextToCubeStoreRouterIdFn | null; + protected readonly preAggregationsSchema: PreAggregationsSchemaFn; protected readonly orchestratorOptions: OrchestratorOptionsFn; @@ -192,6 +196,7 @@ export class CubejsServerCore { } this.contextToOrchestratorId = this.options.contextToOrchestratorId || (() => 'STANDALONE'); + this.contextToCubeStoreRouterId = this.options.contextToCubeStoreRouterId; // proactively free up old cache values occasionally if (this.options.maxCompilerCacheKeepAlive) { diff --git a/packages/cubejs-server-core/src/core/types.ts b/packages/cubejs-server-core/src/core/types.ts index b5280b69b71f7..213bc9c2ac7a8 100644 --- a/packages/cubejs-server-core/src/core/types.ts +++ b/packages/cubejs-server-core/src/core/types.ts @@ -122,6 +122,7 @@ export type DatabaseType = export type ContextToAppIdFn = (context: RequestContext) => string | Promise; export type ContextToRolesFn = (context: RequestContext) => string[] | Promise; export type ContextToOrchestratorIdFn = (context: RequestContext) => string | Promise; +export type ContextToCubeStoreRouterIdFn = (context: RequestContext) => string | Promise; export type OrchestratorOptionsFn = (context: RequestContext) => OrchestratorOptions | Promise; @@ -179,6 +180,7 @@ export interface CreateOptions { contextToAppId?: ContextToAppIdFn; contextToRoles?: ContextToRolesFn; contextToOrchestratorId?: ContextToOrchestratorIdFn; + contextToCubeStoreRouterId?: ContextToCubeStoreRouterIdFn; contextToApiScopes?: ContextToApiScopesFn; repositoryFactory?: (context: RequestContext) => SchemaFileRepository; checkAuth?: CheckAuthFn;