Crate 依赖图 / Crate Dependency Map
C4 对应视图 / C4 Counterparts
本页描述编译时 crate 依赖;可部署单元见 C4 Container 图,crate 内部结构见:
This page describes compile-time crate dependencies. For deployable units, see the C4 Container diagram; for crate internals, see:
- rr-server → c4/components-server.md
- rr-raft → c4/components-raft.md
- rr-router + rr-config → c4/components-router.md
- rr-network → c4/components-network.md
依赖关系 / Dependency Graph
依赖按层划分,图中无循环依赖。
Dependencies are layered, with no cycles in this graph.
查看 PlantUML 源码 / View PlantUML source
@startuml
title Crate Dependency Graph - Rr Framework
skinparam componentStyle rectangle
skinparam component {
BackgroundColor<<foundation>> #FFF4C2
BackgroundColor<<infra>> #C8E0F4
BackgroundColor<<orchestration>> #D5E8D4
BackgroundColor<<app>> #F8CECC
}
package "Foundation" {
[rr-core] <<foundation>>
}
package "Infrastructure" {
[rr-config] <<infra>>
[rr-config-etcd] <<infra>>
[rr-storage] <<infra>>
[rr-raft] <<infra>>
[rr-network] <<infra>>
[rr-router] <<infra>>
[rr-ingestor-kafka] <<infra>>
}
package "Orchestration" {
[rr-server] <<orchestration>>
}
package "Application" {
[rr-client] <<app>>
[rr-admin] <<app>>
}
[rr-config] --> [rr-core]
[rr-config-etcd] --> [rr-core]
[rr-storage] --> [rr-core]
[rr-raft] --> [rr-core]
[rr-raft] --> [rr-storage]
[rr-raft] --> [rr-client]
[rr-network] --> [rr-core]
[rr-router] --> [rr-core]
[rr-ingestor-kafka] --> [rr-core]
[rr-server] --> [rr-core]
[rr-server] --> [rr-raft]
[rr-server] --> [rr-network]
[rr-server] --> [rr-router]
[rr-server] --> [rr-config]
[rr-server] --> [rr-config-etcd]
[rr-server] --> [rr-storage]
[rr-client] --> [rr-core]
[rr-client] --> [rr-network]
[rr-admin] --> [rr-core]
[rr-admin] --> [rr-network]
[rr-admin] --> [rr-config-etcd]
@enduml
Crate 说明 / Crate Details
| Crate | 层级 / Layer | 用途与关键类型 / Purpose and Key Types |
|---|---|---|
rr-core | 基础 Foundation | 错误、核心 trait 和公共类型:RrError, NodeId, GroupId, Service, StateMachine, StorageEngine, ConfigProvider。Errors, core traits, and shared types: RrError, NodeId, GroupId, Service, StateMachine, StorageEngine, ConfigProvider. |
rr-config | 基础设施 Infrastructure | 内存配置提供者:MemConfigProvider。In-memory configuration provider: MemConfigProvider. |
rr-config-etcd | 基础设施 Infrastructure | 只读 etcd 配置、路由读取与 watch、节点目录:EtcdConfigProvider、EtcdNodeDirectory。Read-only etcd configuration, routing reads and watches, and node directory: EtcdConfigProvider, EtcdNodeDirectory. |
rr-storage | 基础设施 Infrastructure | 内存与 RocksDB 后端:MemStorage、RocksStorage(rocks feature)。Memory and RocksDB backends: MemStorage and RocksStorage (rocks feature). |
rr-raft | 基础设施 Infrastructure | 基于 openraft 的共识引擎:RaftGroupManager, RaftNode, RrTypeConfig。openraft-based consensus: RaftGroupManager, RaftNode, RrTypeConfig. |
rr-network | 基础设施 Infrastructure | gRPC 传输:RaftServiceImpl, ClientServiceImpl, ChannelPool, BearerInterceptor, RateLimitInterceptor。gRPC transport: RaftServiceImpl, ClientServiceImpl, ChannelPool, BearerInterceptor, RateLimitInterceptor. |
rr-router | 基础设施 Infrastructure | 分片路由:ShardRouter。Shard routing: ShardRouter. |
rr-ingestor-kafka | 基础设施 Infrastructure | Kafka CommandIngestor 后端;默认仅内存 mock,真实后端需 rdkafka feature:KafkaIngestor, MockKafkaIngestor, KafkaIngestorConfig。Kafka CommandIngestor backend; memory mock by default, real backend requires the rdkafka feature: KafkaIngestor, MockKafkaIngestor, KafkaIngestorConfig. |
rr-client | 应用 Application | 客户端 SDK:RrClient, RetryConfig。Client SDK: RrClient, RetryConfig. |
rr-admin | 应用 Application | 运维 CLI/REPL(备份、下线、重置等受控操作)与同源只读 Console BFF(Axum,静态导出、版本化 JSON 与 SSE);通过 rr-config-etcd 支持可选 etcd 发现。Next.js 前端导出由 BFF 托管,不是 Rust crate;二进制 crate,无库类型。Operations CLI/REPL for controlled actions such as backup, decommission, and reset, plus a same-origin read-only Console BFF (Axum, static export, versioned JSON, and SSE); uses rr-config-etcd for optional etcd discovery. The BFF serves the Next.js frontend export, which is not a Rust crate; binary crate with no library types. |
rr-server | 编排 Orchestration | 节点生命周期管理:RrNode, NodeConfig。Node lifecycle management: RrNode, NodeConfig. |
特性标志 / Feature Flags
rocks:在rr-storage、rr-raft和rr-server中可用;rr-server/rocks同时启用rr-storage/rocks与rr-raft/rocks,提供 RocksDB 后端和RocksLogStorage。
Available inrr-storage,rr-raft, andrr-server;rr-server/rocksforwards torr-storage/rocksandrr-raft/rocks, enabling the RocksDB backend andRocksLogStorage.defensive:在rr-raft中可用,为日志存储增加一致性校验;也可在运行时设置RR_STORE_DEFENSIVE=on,无需重新编译。
Thedefensivefeature is available inrr-raftto add log-storage consistency checks; it can also be enabled at runtime withRR_STORE_DEFENSIVE=onwithout recompiling.
分层职责 / Layer Responsibilities
- 基础层:定义公共类型和 trait 契约。
FoundationDefines shared types and trait contracts. - 基础设施:实现网络、共识、存储、路由和配置。
InfrastructureImplements networking, consensus, storage, routing, and configuration. - 编排层:把组件组装为服务节点。
OrchestrationAssembles components into a server node. - 应用层:提供客户端和运维入口。
ApplicationProvides client and operations entry points.