🚀 数据库服务API

高性能、高可用的数据库访问服务

✅ 运行中

🔌 连接管理

  • 连接池管理(2-20个连接)
  • 自动重连机制
  • 连接健康检查
  • 并发访问控制

⚡ 性能优化

  • 查询结果缓存
  • CDN友好响应头
  • TCP_NODELAY优化
  • 响应压缩

🛡️ 容错机制

  • 网络中断自动重试
  • 超时控制
  • 事务支持
  • 优雅降级

📊 监控管理

  • 健康检查接口
  • 连接池状态监控
  • 请求日志记录
  • 性能指标统计

📖 API接口文档

GET /health

健康检查接口

GET /health // 响应 { "success": true, "data": { "status": "healthy", "latency_ms": 2.35, "connections": { "total_connections": 5, "available": 3, "in_use": 2, "wait_queue": 0, "max_connections": 20 }, "timestamp": "2026-01-23 10:30:00" } }

GET /stats

系统状态统计

GET /tables/{table}

查询数据(支持条件过滤、分页)

GET /tables/users?page=1&limit=20&status=active&order_by=id DESC // 响应 { "success": true, "data": { "data": [...], "pagination": { "page": 1, "limit": 20, "total": 156, "pages": 8 } } }

POST /tables/{table}

插入数据(支持批量插入)

POST /tables/users { "name": "张三", "email": "zhangsan@example.com", "status": "active" } // 批量插入 POST /tables/users [ {"name": "张三", "email": "zhangsan@example.com"}, {"name": "李四", "email": "lisi@example.com"} ]

PUT /tables/{table}

更新数据

PUT /tables/users { "data": { "status": "inactive", "updated_at": "2026-01-23 10:30:00" }, "conditions": { "id": 123 } }

DELETE /tables/{table}

删除数据

DELETE /tables/users { "id": 123 } // 或使用IN条件 DELETE /tables/users { "id": [123, 124, 125] }

POST /query

执行自定义查询(只读)

POST /query { "sql": "SELECT * FROM users WHERE status = ? LIMIT ?", "params": ["active", 10], "types": "si" }