1#![deny(unused_must_use)]
11#![warn(missing_docs)]
12
13mod config;
14mod error;
15mod hash;
16mod ring;
17mod route;
18mod table;
19
20pub use config::{
21 ClusterConfig, ComputeSpec, DEFAULT_ADMIN_URL, DEFAULT_COMPUTE_ID, DEFAULT_RDF4J_URL,
22 RegistryNodeId,
23};
24pub use error::RouterError;
25pub use hash::{hash_term, murmur3_32};
26pub use ring::HashRing;
27pub use route::{
28 Route, RoutedNode, Router, RoutingSnapshot, routing_term, select_axis, select_target,
29};
30pub use table::RoutingTable;
31pub use waratah_storage::{EncodedTerm, EncodedTriplePattern, PartitionAxis};
32
33use std::fmt;
34
35#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
37pub struct NodeId(String);
38
39impl NodeId {
40 pub fn new(id: impl Into<String>) -> Self {
42 Self(id.into())
43 }
44
45 pub fn as_str(&self) -> &str {
47 &self.0
48 }
49}
50
51impl fmt::Display for NodeId {
52 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
53 f.write_str(&self.0)
54 }
55}
56
57impl From<&str> for NodeId {
58 fn from(value: &str) -> Self {
59 Self::new(value)
60 }
61}
62
63impl From<String> for NodeId {
64 fn from(value: String) -> Self {
65 Self::new(value)
66 }
67}
68
69impl AsRef<str> for NodeId {
70 fn as_ref(&self) -> &str {
71 self.as_str()
72 }
73}