Skip to main content

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:

依赖关系 / Dependency Graph​

依赖按层划分,图中无循环依赖。

Dependencies are layered, with no cycles in this graph.

架构图 / Architecture diagram查看原图 / Open full size
Crate Dependency Graph - Rr Framework
查看 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 in rr-storage, rr-raft, and rr-server; rr-server/rocks forwards to rr-storage/rocks and rr-raft/rocks, enabling the RocksDB backend and RocksLogStorage.
  • defensive:在 rr-raft 中可用,为日志存储增加一致性校验;也可在运行时设置 RR_STORE_DEFENSIVE=on,无需重新编译。
    The defensive feature is available in rr-raft to add log-storage consistency checks; it can also be enabled at runtime with RR_STORE_DEFENSIVE=on without recompiling.

分层职责 / Layer Responsibilities​

  1. 基础层:定义公共类型和 trait 契约。
    FoundationDefines shared types and trait contracts.
  2. 基础设施:实现网络、共识、存储、路由和配置。
    InfrastructureImplements networking, consensus, storage, routing, and configuration.
  3. 编排层:把组件组装为服务节点。
    OrchestrationAssembles components into a server node.
  4. 应用层:提供客户端和运维入口。
    ApplicationProvides client and operations entry points.