cube.js 配置json schema

通过对与cube 配置的json schema 学习我们可以知道cube.js 都包含了那些扩展点,可以方便系统的扩容以及优化

内容

const schemaOptions = Joi.object().keys({
  // server CreateOptions
  initApp: Joi.func(),
  webSockets: Joi.boolean(),
  http: Joi.object().keys({
    cors: Joi.object(),
  }),
  gracefulShutdown: Joi.number().min(0).integer(),
  // Additional from WebSocketServerOptions
  processSubscriptionsInterval: Joi.number(),
  webSocketsBasePath: Joi.string(),
  // server-core CoreCreateOptions
  dbType: dbTypes,
  externalDbType: dbTypes,
  schemaPath: Joi.string(),
  basePath: Joi.string(),
  devServer: Joi.boolean(),
  apiSecret: Joi.string(),
  logger: Joi.func(),
  // source
  dialectFactory: Joi.func(),
  driverFactory: Joi.func(),
  // external
  externalDialectFactory: Joi.func(),
  externalDriverFactory: Joi.func(),
  //
  cacheAndQueueDriver: Joi.string().valid('redis', 'memory'),
  contextToAppId: Joi.func(),
  contextToOrchestratorId: Joi.func(),
  contextToDataSourceId: Joi.func(),
  repositoryFactory: Joi.func(),
  checkAuth: Joi.func(),
  checkAuthMiddleware: Joi.func(),
  jwt: jwtOptions,
  queryTransformer: Joi.func(),
  queryRewrite: Joi.func(),
  preAggregationsSchema: Joi.alternatives().try(
    Joi.string(),
    Joi.func()
  ),
  schemaVersion: Joi.func(),
  extendContext: Joi.func(),
  // Scheduled refresh
  scheduledRefreshTimer: Joi.alternatives().try(
    Joi.boolean(),
    Joi.number().min(0).integer()
  ),
  scheduledRefreshTimeZones: Joi.array().items(Joi.string()),
  scheduledRefreshContexts: Joi.func(),
  scheduledRefreshConcurrency: Joi.number().min(1).integer(),
  // Compiler cache
  compilerCacheSize: Joi.number().min(0).integer(),
  updateCompilerCacheKeepAlive: Joi.boolean(),
  maxCompilerCacheKeepAlive: Joi.number().min(0).integer(),
  telemetry: Joi.boolean(),
  allowUngroupedWithoutPrimaryKey: Joi.boolean(),
  orchestratorOptions: Joi.alternatives().try(
    Joi.func(),
    Joi.object().keys({
      redisPrefix: Joi.string().allow(''),
      redisPoolOptions: Joi.object().keys({
        poolMin: Joi.number().min(0),
        poolMax: Joi.number().min(0),
        idleTimeoutSeconds: Joi.number().min(0),
        softIdleTimeoutSeconds: Joi.number().min(0),
        createClient: Joi.func(),
        destroyClient: Joi.func(),
        poolOptions: Joi.object().keys({
          maxWaitingClients: Joi.number(),
          testOnBorrow: Joi.bool(),
          testOnReturn: Joi.bool(),
          acquireTimeoutMillis: Joi.number(),
          fifo: Joi.bool(),
          priorityRange: Joi.number(),
          autostart: Joi.bool(),
          evictionRunIntervalMillis: Joi.number().min(0),
          numTestsPerEvictionRun: Joi.number().min(1),
          softIdleTimeoutMillis: Joi.number().min(0),
          idleTimeoutMillis: Joi.number().min(0),
        })
      }),
      continueWaitTimeout: Joi.number().min(0).integer(),
      skipExternalCacheAndQueue: Joi.boolean(),
      queryCacheOptions: Joi.object().keys({
        refreshKeyRenewalThreshold: Joi.number().min(0).integer(),
        backgroundRenew: Joi.boolean(),
        queueOptions: schemaQueueOptions,
        externalQueueOptions: schemaQueueOptions
      }),
      preAggregationsOptions: {
        queueOptions: schemaQueueOptions,
        externalRefresh: Joi.boolean(),
      },
      rollupOnlyMode: Joi.boolean()
    })
  ),
  allowJsDuplicatePropsInSchema: Joi.boolean(),
  dashboardAppPath: Joi.string(),
  dashboardAppPort: Joi.number(),
  sqlCache: Joi.boolean(),
  livePreview: Joi.boolean(),
  // SQL API
  sqlPort: Joi.number(),
  pgSqlPort: Joi.number(),
  checkSqlAuth: Joi.func(),
  sqlUser: Joi.string(),
  sqlPassword: Joi.string(),
  // Additional system flags
  serverless: Joi.boolean(),
  allowNodeRequire: Joi.boolean(),
});

参考资料

https://github.com/cube-js/cube.js/blob/36b65ef40415a3fdf6cbbcc0a6d1a6b345add1c5/packages/cubejs-server-core/src/core/optionsValidate.ts

posted on 2022-06-11 09:39  荣锋亮  阅读(87)  评论(0编辑  收藏  举报

导航