Creates a new entangledb server. Initializes a new server instance with the provided Raft configuration. # Arguments `id` - The unique identifier for the Raft node. `peers` - A map of peer node IDs to their associated network addresses. `raft_log` - The Raft log implementation. `raft_state` - The persistent state storage for the Raft consensus algorithm. # Returns A result containing the new ser
(
id: raft::NodeID,
peers: HashMap<raft::NodeID, String>,
raft_log: raft::Log,
raft_state: Box<dyn raft::State>,
)
| 39 | /// # Returns |
| 40 | /// A result containing the new server instance or an error if initialization fails. |
| 41 | pub async fn new( |
| 42 | id: raft::NodeID, |
| 43 | peers: HashMap<raft::NodeID, String>, |
| 44 | raft_log: raft::Log, |
| 45 | raft_state: Box<dyn raft::State>, |
| 46 | ) -> Result<Self> { |
| 47 | Ok(Server { |
| 48 | raft: raft::Server::new(id, peers, raft_log, raft_state).await?, |
| 49 | raft_listener: None, |
| 50 | sql_listener: None, |
| 51 | }) |
| 52 | } |
| 53 | |
| 54 | /// Starts listening on the given ports. Must be called before serve. |
| 55 | /// Sets up the TCP listeners for both SQL and Raft communication. |