rocketmq_controller/lib.rs
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18//! # RocketMQ Controller Module
19//!
20//! High-availability controller implementation for RocketMQ, providing:
21//! - Raft-based consensus for leader election and metadata replication
22//! - Broker registration and heartbeat management
23//! - Topic metadata management and synchronization
24//! - Configuration management across the cluster
25//!
26//! ## Architecture
27//!
28//! ```text
29//! ┌─────────────────────────────────────────┐
30//! │ Controller Manager (Entry) │
31//! └──────────────┬──────────────────────────┘
32//! │
33//! ┌───────┴────────┐
34//! │ │
35//! ┌──────▼──────┐ ┌─────▼──────┐
36//! │ Raft Module │ │ Processor │
37//! │ (raft-rs) │ │ Layer │
38//! └──────┬──────┘ └─────┬──────┘
39//! │ │
40//! └────────┬───────┘
41//! │
42//! ┌────────▼─────────┐
43//! │ Metadata Store │
44//! │ (DashMap/Raft) │
45//! └──────────────────┘
46//! ```
47//!
48//! ## Usage
49//!
50//! ```rust,ignore
51//! use rocketmq_controller::ControllerConfig;
52//! use rocketmq_controller::ControllerManager;
53//!
54//! #[tokio::main]
55//! async fn main() -> anyhow::Result<()> {
56//! let config = ControllerConfig::default();
57//! let mut controller = ControllerManager::new(config)?;
58//!
59//! controller.start().await?;
60//!
61//! // Controller is now running...
62//!
63//! controller.shutdown().await?;
64//! Ok(())
65//! }
66//! ```
67
68#![warn(rust_2018_idioms)]
69#![warn(clippy::all)]
70#![allow(dead_code)]
71#![allow(clippy::module_inception)]
72
73pub mod config;
74pub mod error;
75pub mod manager;
76pub mod metadata;
77pub mod processor;
78pub mod raft;
79pub mod rpc;
80pub mod storage;
81
82pub use config::ControllerConfig;
83pub use error::ControllerError;
84pub use error::Result;
85pub use manager::ControllerManager;
86
87/// Controller module version
88pub const VERSION: &str = env!("CARGO_PKG_VERSION");
89
90/// Default controller listen port
91pub const DEFAULT_CONTROLLER_PORT: u16 = 9878;
92
93#[cfg(test)]
94mod tests {
95 use super::*;
96
97 #[test]
98 fn test_version() {
99 assert!(!VERSION.is_empty());
100 }
101}