d-engine-server 0.2.3

Production-ready Raft consensus engine server and runtime
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use tokio::net::TcpStream;

/// accept ip either like 127.0.0.1 or docker host name: node1
pub(crate) fn address_str(addr: &str) -> String {
    // Strip existing "http://" or "https://" prefixes if duplicated.
    let normalized = addr.trim_start_matches("http://").trim_start_matches("https://");
    // Re-add a single "http://" prefix (or use HTTPS if needed).
    format!("http://{normalized}")
}

pub(crate) async fn is_server_ready(addr: &str) -> bool {
    TcpStream::connect(addr).await.is_ok()
}