cube.js 0.30.30 配置的一些变动

好久没关注cube.js 最近0.30.30 有一个比较大的变动就是driverFactory

新配置

  driverFactory: (context: DriverContext) => DriverConfig | BaseDriver | Promise<BaseDriver>;

此配置的影响

此配置会对于开发的自定义驱动有一些影响,推荐的是自己开发的driver 也添加一个type 的定义

const PostgresDriver = require('@cubejs-backend/postgres-driver');
module.exports = {
  driverFactory: ({ dataSource }) =>
    new PostgresDriver({ database: dataSource }),
  dbType: ({ dataSource }) => 'postgres',
};

一个参考dremio 的driver, 详细源码参考github

constructor(config = {}) {
super();
// for cube.js latest version, if we write one custome driver should add this 
this.type="mydremio";
this.config = {
  host: config.host || process.env.CUBEJS_DB_HOST || 'localhost',
  port: config.port || process.env.CUBEJS_DB_PORT || 9047,
  user: config.user || process.env.CUBEJS_DB_USER,
  password: config.password || process.env.CUBEJS_DB_PASS,
  database: config.database || process.env.CUBEJS_DB_NAME,
  ssl: config.ssl || process.env.CUBEJS_DB_SSL,
  ...config,
  pollTimeout: (config.pollTimeout || getEnv('dbPollTimeout') || getEnv('dbQueryTimeout')) * 1000,
  pollMaxInterval: (config.pollMaxInterval || getEnv('dbPollMaxInterval')) * 1000,
};
 
const protocol = (this.config.ssl === true || this.config.ssl === 'true') ? 'https' : 'http';
 
this.config.url = `${protocol}://${this.config.host}:${this.config.port}`;
}

说明

新版本的cube.js 对于调度也有依一些调整了,默认是共享的,如果需要,自定义可以扩展

module.exports = {
  contextToAppId: ({ securityContext }) =>
    `CUBEJS_APP_${securityContext.tenantId}`,
  contextToOrchestratorId: ({ securityContext }) =>
    `CUBEJS_APP_${securityContext.tenantId}`,
};

新版本变动还是不少的,值得深入学习研究下(目前测试,性能提升也是不少, 推荐开发自定义driver 严格使用-cubejs-driver

参考资料

https://cube.dev/docs/config#options-reference-driver-factory
https://github.com/rongfengliang/cubejs-dremio-driver.git

posted on   荣锋亮  阅读(48)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2020-07-14 Easy Python Decompiler 一个很不错的python pyc 反编译工具
2020-07-14 HAProxy Process Management
2020-07-14 pgx zombodb 团队开源的基于rust 开发pg扩展

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示