pub struct FabricDns { /* private fields */ }Expand description
Fabric DNS resolver for mapping node names to socket addresses.
Provides name registration and lookup with TTL-based cache expiry.
Names follow the <node_id>.fabric or <human_name>.fabric convention.
This is an in-memory implementation suitable for testing and single-process use. A production implementation would query the fabricBIOS control plane.
§Example
use grafos_net::FabricDns;
use std::net::SocketAddr;
use std::time::Duration;
let mut dns = FabricDns::new(Duration::from_secs(300));
let addr: SocketAddr = "10.10.0.11:5701".parse().unwrap();
dns.register("node-b.fabric", addr);
let resolved = dns.resolve("node-b.fabric").unwrap();
assert_eq!(resolved, vec![addr]);Implementations§
Source§impl FabricDns
impl FabricDns
Sourcepub fn new(ttl: Duration) -> Self
pub fn new(ttl: Duration) -> Self
Create a new DNS resolver with the given TTL for cached entries.
Sourcepub fn register(&mut self, name: &str, addr: SocketAddr)
pub fn register(&mut self, name: &str, addr: SocketAddr)
Register a name-to-address mapping.
If the name already exists, the entry is replaced with a fresh TTL.
Sourcepub fn resolve(&self, name: &str) -> Option<Vec<SocketAddr>>
pub fn resolve(&self, name: &str) -> Option<Vec<SocketAddr>>
Resolve a fabric node name to its registered addresses.
Returns None if the name is not registered or has expired.
Sourcepub fn evict_expired(&mut self)
pub fn evict_expired(&mut self)
Remove expired entries from the cache.
Auto Trait Implementations§
impl Freeze for FabricDns
impl RefUnwindSafe for FabricDns
impl Send for FabricDns
impl Sync for FabricDns
impl Unpin for FabricDns
impl UnwindSafe for FabricDns
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more