Hiver Framework
A production-grade, high-availability web framework written in Rust.
Hiver 框架
用 Rust 编写的生产级、高可用 Web 框架。
Why Hiver? / 为什么选择 Hiver?
🚀 Custom io-uring RuntimeCustom async runtime built from scratch with io-uring (Linux), epoll, and kqueue (macOS). Thread-per-core architecture for linear scalability. 自定义 io-uring 运行时从零构建的自定义异步运行时,支持 io-uring、epoll 和 kqueue。Thread-per-core 架构实现线性扩展。 |
🏗️ Spring-like Annotations40+ procedural macro annotations inspired by Spring Boot: 类 Spring 注解40+ 过程宏注解,灵感来自 Spring Boot: |
🛡️ Resilience Built-inCircuit breakers, rate limiters, retry logic, and service discovery — production patterns out of the box. 内置弹性模式熔断器、限流器、重试逻辑和服务发现 — 开箱即用的生产级模式。 |
🌐 Web3 NativeFirst-class Ethereum support via Alloy: wallet management, smart contracts, RPC client, and chain abstraction. Web3 原生支持通过 Alloy 提供一流的以太坊支持:钱包管理、智能合约、RPC 客户端和链抽象。 |
📊 Full ObservabilityDistributed tracing (OpenTelemetry), metrics (Prometheus), and structured logging — zero-config integration. 完整可观测性分布式追踪(OpenTelemetry)、指标(Prometheus)和结构化日志 — 零配置集成。 |
🗄️ Data Layer (In Progress)Spring Data-like abstractions: Repository traits, ORM, ActiveRecord, QueryBuilder, and multi-database support. 数据层(开发中)类 Spring Data 抽象:Repository trait、ORM、ActiveRecord、QueryBuilder 和多数据库支持。 |
Quick Start / 快速开始
# Cargo.toml
[dependencies]
hiver-starter = "0.1"
use hiver_starter::HiverApp;
use hiver_router::Router;
#[hiver::handler]
async fn hello() -> &'static str {
"Hello, Hiver! / 你好,Hiver!"
}
fn main() -> std::io::Result<()> {
HiverApp::new()
.with_router(Router::new()
.get("/", hello)
.get("/users/:id", get_user)
.post("/users", create_user)
)
.run()
}
Performance / 性能
| Metric | Target | Status |
|---|---|---|
| Simple GET QPS | 1M+ | ✅ Achieved |
| P99 Latency (no middleware) | < 1ms | ✅ Achieved |
| Base Memory | < 10MB | ✅ Achieved |
| Startup Time | < 100ms | ✅ Achieved |
Architecture / 架构
┌─────────────────────────────────────────────┐
│ Application Layer │
├──────────┬──────────┬──────────┬────────────┤
│ HTTP │ Resilience│Observab. │ Web3 │
│ Router │ & HA │ Tracing │ Ethereum │
├──────────┴──────────┴──────────┴────────────┤
│ Core Framework (62 crates) │
├──────────┬──────────┬──────────┬────────────┤
│ Handlers │Extractors│Middleware│ Data │
├──────────┴──────────┴──────────┴────────────┤
│ Custom Async Runtime │
├──────────┬──────────┬──────────┬────────────┤
│ io-uring │ Thread- │ Timer │ MPSC │
│ Driver │per-core │ Wheel │ Channels │
└──────────┴──────────┴──────────┴────────────┘
10 domains, 62 crates — full Spring Boot feature parity in Rust.
Project Status / 项目状态
| Phase | Description | Status |
|---|---|---|
| 0 | Foundation (CI/CD, docs) | ✅ Complete |
| 1 | Runtime Core (io-uring, scheduler) | ✅ Complete |
| 2 | HTTP Core (server, router, extractors) | ✅ Complete |
| 3 | Middleware & Extensions | ✅ Complete |
| 4 | Resilience (circuit breaker, retry) | ✅ Complete |
| 5 | Observability (tracing, metrics) | ✅ Complete |
| 6 | Web3 Support (Ethereum, wallets) | ✅ Complete |
| 7 | Production Ready (optimization, security) | ✅ Complete |
| 8 | Data Layer (ORM, migrations) | 🔄 In Progress |
Resources / 资源
| Resource | Link |
|---|---|
| 📦 Crates.io | hiver-framework |
| 📖 API Docs | docs.rs/hiver |
| 💻 GitHub | ViewWay/hiver |
| 📄 Design Spec | design-spec.md |
| 🗺️ Implementation Plan | implementation-plan.md |
Spring Boot Equivalents / Spring Boot 对比
| Spring Boot | Hiver | Description |
|---|---|---|
@RestController | #[handler] | HTTP handler |
@GetMapping | #[get("/path")] | GET endpoint |
@Autowired | #[inject] | DI injection |
@Repository | #[derive(Repository)] | Data repository |
@ConfigurationProperties | #[derive(PropertiesConfig)] | Config binding |
SpringApplication.run() | HiverApp::new().run() | App bootstrap |
@SpringBootApplication | hiver-starter | Auto-config |
| Resilience4j | hiver-resilience | Circuit breaker |
| Spring Security | hiver-security | Auth & security |
| Spring Data JPA | hiver-data-orm | ORM abstraction |
| Spring WebFlux | hiver-http | HTTP server |
Get Started → Installation