GitHub - APIJSON/apijson-rust: Rust 版 APIJSON - 🏆 实时 零代码、全功能、强安全 ORM 库 🚀 后端接口和文档零代码,前端(客户端) 定制返回 JSON 的数据和结构
Repository navigation
apijson-rustPublic
About
Rust 版 APIJSON - 🏆 实时 零代码、全功能、强安全 ORM 库 🚀 后端接口和文档零代码,前端(客户端) 定制返回 JSON 的数据和结构
apijson.cnTopics
apijson database mysql mysql-database orm orm-framework orm-library postgres postgresql postgresql-database rust rust-lang rust-library rustlangResources
Readme Activity Custom propertiesStars
6 starsWatchers
1 watchingForks
1 fork Report repositoryBranches
Tags
Go to Branches page Go to Tags page
Latest commit
History
36 Commits
View commit history for this file.
Folders and files
| Name | Name | Last commit message | Last commit date |
|---|---|---|---|
| .docker | .docker | ||
| .github/ workflows | .github/ workflows | ||
| .idea | .idea | ||
| src | src | ||
| .env | .env | ||
| .gitignore | .gitignore | ||
| Cargo.lock | Cargo.lock | ||
| Cargo.toml | Cargo.toml | ||
| README.md | README.md | ||
| application.yaml | application.yaml | ||
| docker-compose.yaml | docker-compose.yaml | ||
Repository files navigation
APIJSON-Rust
APIJSON Rust 版 - 🏆 实时 零代码、全功能、强安全 ORM 库 🚀
后端接口和文档零代码,前端(客户端) 定制返回 JSON 的数据和结构。
包含一个优雅、高性能的多数据源管理系统,支持 MySQL, PostgreSQL 等统一管理和操作。
🚀 特性
- 多数据源支持 : 同时管理多个 MySQL 和 PostgreSQL 数据源
- 统一接口 : 提供统一的数据库操作接口,屏蔽底层数据库差异
- 智能缓存 : 内置高效的元数据缓存系统,支持数据源、数据库、表的关联查询
- 配置驱动 : 基于 YAML 配置文件的声明式配置管理
- 异步支持 : 基于 Tokio 的异步运行时,支持高并发操作
- 类型安全 : 利用 Rust 的类型系统确保运行时安全
🛠️ 安装和配置
1. 克隆项目
git clone <repository-url> cd panda-base
2. 安装依赖
cargo build
3. 配置数据源
编辑 application.yaml 文件:
datasources:
# MySQL 数据源
- name: ds_mysql
kind: mysql
username: root
password: "123456"
url: "mysql://root:123456@localhost:3306"
database: ["db1", "db2", "db3"]
default: true
# PostgreSQL 数据源
- name: ds_pg
kind: postgres
username: postgres
password: "123456"
url: "postgres://postgres:123456@localhost:5432"
database: ["db4", "db5", "db6"]
default: false
4. 运行应用
cargo run
📊 性能特性
- 连接池 : 自动管理数据库连接池,支持高并发访问
- 智能缓存 : 元数据缓存命中率 > 95%
- 异步操作 : 基于 Tokio 的异步 I/O,支持数千并发连接
- 内存优化 : 使用
Arc和RwLock实现高效的内存共享
🔧 配置选项
数据源配置
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
name |
String | ✅ | 数据源唯一名称 |
kind |
Enum | ✅ | 数据库类型 (mysql/postgres) |
username |
String | ✅ | 数据库用户名 |
password |
String | ✅ | 数据库密码 |
url |
String | ✅ | 数据库连接 URL |
database |
Array | ✅ | 数据库名称列表 |
default |
Boolean | ✅ | 是否为默认数据源 |
URL 格式
- MySQL :
mysql://[username:password@]host:port[/database] - PostgreSQL :
postgres://[username:password@]host:port[/database]
🚨 注意事项
-
唯一性约束 :
- 数据源名称必须唯一
- 必须有且仅有一个默认数据源
-
性能优化 :
- 合理配置连接池大小
- 定期清理缓存数据
- 监控数据库连接状态
🗺️ 路线图
- 支持更多数据库类型 (SQLite, Oracle)
- 添加数据库迁移工具
- 实现读写分离
- 添加监控和指标收集
- 支持分布式缓存
- 添加 Web 管理界面
测试环境运行
初始化数据库
docker compose up -d
概念、对比及接口使用文档
https://github.com/APIJSON/APIJSON/blob/master/Document-Chinese.md
反馈问题或建议
有问题可以去 APIJSON 主项目提 issue:
https://github.com/APIJSON/APIJSON/issues
项目申明
本项目来源于 fork https://gitee.com/panda-ai/panda-base ,官方介绍是 APIJSON Rust 版,
但我发现基础功能及实现和 APIJSON 规范稍有差异,所以调整至严格遵循 APIJSON 规范并可用后提了 PR,
但 Gitee 上原作者 @ReliefZk_admin(GitHub 上可能是 @zk-hillresearch) 未合并,后面还删除了上游仓库,
所以我保留了仓库,方便需要的开发者使用及继续完善,希望大家可以直接贡献或者另开 Rust 版时有所参考。
非常感谢原作者对该项目及 APIJSON 生态的贡献,如果觉得有不合适的请联系 tommylemon@qq.com 处理,谢谢~
我要赞赏
创作不易,右上角点亮 ⭐Star 来支持/收藏下吧,谢谢 ^_^
https://github.com/APIJSON/apijson-rust
About
Rust 版 APIJSON - 🏆 实时 零代码、全功能、强安全 ORM 库 🚀 后端接口和文档零代码,前端(客户端) 定制返回 JSON 的数据和结构
apijson.cn