Skip to content

Commit 48ca5aa

Browse files
authored
fix(@cubejs-backend/server-core): orchestratorOptions validation breaks serverless deployments (#1113)
1 parent 98ffad3 commit 48ca5aa

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,23 @@ describe('index.test', () => {
4848
.toThrowError(/"compilerCacheSize" must be larger than or equal to 0/);
4949
});
5050

51+
52+
test('Should create instance of CubejsServerCore, orchestratorOptions as func', () => {
53+
const options = { dbType: 'mysql', orchestratorOptions: () => {} };
54+
55+
expect(new CubejsServerCore(options))
56+
.toBeInstanceOf(CubejsServerCore);
57+
});
58+
5159
test('Should create instance of CubejsServerCore, pass all options', () => {
5260
const queueOptions = {
5361
concurrency: 3,
5462
continueWaitTimeout: 5,
5563
executionTimeout: 600,
5664
orphanedTimeout: 120,
57-
heartBeatInterval: 500
65+
heartBeatInterval: 500,
66+
sendProcessMessageFn: () => {},
67+
sendCancelMessageFn: () => {}
5868
};
5969

6070
const options = {
@@ -87,7 +97,10 @@ describe('index.test', () => {
8797
queryCacheOptions: {
8898
refreshKeyRenewalThreshold: 1000,
8999
backgroundRenew: true,
90-
queueOptions
100+
queueOptions,
101+
externalQueueOptions: {
102+
...queueOptions
103+
}
91104
},
92105
preAggregationsOptions: {
93106
queueOptions

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

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ const schemaQueueOptions = Joi.object().keys({
77
continueWaitTimeout: Joi.number().min(0).integer(),
88
executionTimeout: Joi.number().min(0).integer(),
99
orphanedTimeout: Joi.number().min(0).integer(),
10-
heartBeatInterval: Joi.number().min(0).integer()
10+
heartBeatInterval: Joi.number().min(0).integer(),
11+
sendProcessMessageFn: Joi.func(),
12+
sendCancelMessageFn: Joi.func(),
1113
});
1214

1315
const dbTypes = Joi.alternatives().try(
@@ -47,17 +49,21 @@ const schemaOptions = Joi.object().keys({
4749
updateCompilerCacheKeepAlive: Joi.boolean(),
4850
telemetry: Joi.boolean(),
4951
allowUngroupedWithoutPrimaryKey: Joi.boolean(),
50-
orchestratorOptions: Joi.object().keys({
51-
redisPrefix: Joi.string().allow(''),
52-
queryCacheOptions: Joi.object().keys({
53-
refreshKeyRenewalThreshold: Joi.number().min(0).integer(),
54-
backgroundRenew: Joi.boolean(),
55-
queueOptions: schemaQueueOptions
56-
}),
57-
preAggregationsOptions: {
58-
queueOptions: schemaQueueOptions
59-
}
60-
}),
52+
orchestratorOptions: Joi.alternatives().try(
53+
Joi.func(),
54+
Joi.object().keys({
55+
redisPrefix: Joi.string().allow(''),
56+
queryCacheOptions: Joi.object().keys({
57+
refreshKeyRenewalThreshold: Joi.number().min(0).integer(),
58+
backgroundRenew: Joi.boolean(),
59+
queueOptions: schemaQueueOptions,
60+
externalQueueOptions: schemaQueueOptions
61+
}),
62+
preAggregationsOptions: {
63+
queueOptions: schemaQueueOptions
64+
}
65+
})
66+
),
6167
allowJsDuplicatePropsInSchema: Joi.boolean(),
6268
scheduledRefreshContexts: Joi.func()
6369
});

0 commit comments

Comments
 (0)