FabricDns

Struct FabricDns 

Source
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

Source

pub fn new(ttl: Duration) -> Self

Create a new DNS resolver with the given TTL for cached entries.

Source

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.

Source

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.

Source

pub fn evict_expired(&mut self)

Remove expired entries from the cache.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.