开发一个 cube.js oceanbase driver

cube.js 去年提供了一个独立的包,方便driver 的开发,尽管oceanbase 是mysql 兼容的,但是在使用一个链接池工具的时候有些问题
所以独立包装了一个oceanbase 的driver

开发说明

基于了官方的mysql driver 对于链接池部分进行了调整,同时进行了重新命名,方便需要维护,具体代码可以参考github
同时注意官方对于三方driver 是不能按照官方仓库模式加载的,需要同时提供query 实现,这点不是很好,自己的实现就需要
做不少配置处理(详细参考下边使用示例)

参考使用

  • cube.js 文件
 
const {OceanBaseQuery,OceanBaseDriver} = require("oceanbase-cubejs-driver")
module.exports = {
    dialectFactory: (dataSource) => {
        // need config  datasource  for multitenant env
        return OceanBaseQuery
    },
    dbType: ({ dataSource } = {}) => {
        return "oceanbase"
    },
    driverFactory: ({ dataSource } = {}) => {
        return new OceanBaseDriver({
            host: xxxxxx,
            port:xxxx,
            database: xxxx,
            user:xxx,
            password: xxxx
        })
    }
};

说明

后边如果时间方便,会尝试合并到cube 官方仓库中,基于独立模式有好处也有坏处,好处是维护方便,坏处是后续进行维护需要与官方发版一致,同时npm 包我已经发布到npm 官方仓库了大家可以直接使用

参考资料

https://github.com/rongfengliang/cubejs-oceanbase-driver
https://cube.dev/docs/config

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

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2022-02-26 apache pinot 学习
2022-02-26 pinot jdbc 连接池工具使用说明
2022-02-26 dremio job 处理流程参考
2022-02-26 dremio cloud 分层datasets 实践
2022-02-26 dremio cloud 参考说明
2022-02-26 dremio yarn 资源调度配置简单说明
2021-02-26 dremio 配置文件

导航

< 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
点击右上角即可分享
微信分享提示