Struct instance_chart::Chart
source · [−]Expand description
The chart keeping track of the discoverd nodes. That a node appears in the chart is no guarentee that it is reachable at this moment.
Implementations
sourceimpl<const N: usize> Chart<N, u16>
impl<const N: usize> Chart<N, u16>
sourcepub fn addr_lists_vec(&self) -> Vec<[SocketAddr; N]>
pub fn addr_lists_vec(&self) -> Vec<[SocketAddr; N]>
Returns an vector with each discovered node’s socketadresses.
Note
- vector order is random
- only availible for Chart configured with
ChartBuilder::with_service_ports
and build usingChartBuilder::finish
.
let chart = ChartBuilder::new()
.with_id(1)
.with_service_ports([8042, 8043, 8044])
.finish()?;
let maintain = discovery::maintain(chart.clone());
let _ = tokio::spawn(maintain); // maintain task will run forever
let port_lists = chart.addr_lists_vec();
sourceimpl<const N: usize> Chart<N, u16>
impl<const N: usize> Chart<N, u16>
sourcepub fn nth_addr_vec<const IDX: usize>(&self) -> Vec<SocketAddr>
pub fn nth_addr_vec<const IDX: usize>(&self) -> Vec<SocketAddr>
Returns a vector over each discoverd node’s nth-socketadress
Note
- vector order is random
- only availible for Chart configured with
ChartBuilder::with_service_ports
and build usingChartBuilder::finish
.
Examples
let web_server_port = 8043;
let chart = ChartBuilder::new()
.with_id(1)
.with_service_ports([8042, web_server_port, 8044])
.finish()?;
let maintain = discovery::maintain(chart.clone());
let _ = tokio::spawn(maintain); // maintain task will run forever
let web_server_ports = chart.nth_addr_vec::<2>();
sourceimpl<'a> Chart<1, u16>
impl<'a> Chart<1, u16>
sourcepub fn addr_vec(&'a self) -> Vec<SocketAddr>
pub fn addr_vec(&'a self) -> Vec<SocketAddr>
Returns a vector over each discoverd nodes’s socketadress
Note
- vector order is random
- only availible for Chart configured with
ChartBuilder::with_service_port
and build usingChartBuilder::finish
.
let chart = ChartBuilder::new()
.with_id(1)
.with_service_port(8042)
.finish()?;
let maintain = discovery::maintain(chart.clone());
let _ = tokio::spawn(maintain); // maintain task will run forever
let ports = chart.addr_vec();
sourceimpl<const N: usize> Chart<N, u16>
impl<const N: usize> Chart<N, u16>
The array of ports set for this chart instance, set in ChartBuilder::with_service_ports
.
pub fn our_service_ports(&self) -> &[u16]
sourceimpl Chart<1, u16>
impl Chart<1, u16>
The port set for this chart instance, set in ChartBuilder::with_service_port
.
pub fn our_service_port(&self) -> u16
sourceimpl<T: Debug + Clone + Serialize> Chart<1, T>
impl<T: Debug + Clone + Serialize> Chart<1, T>
The msg struct for this chart instance, set in ChartBuilder::custom_msg
.
sourceimpl<const N: usize, T: Debug + Clone + Serialize + DeserializeOwned> Chart<N, T>
impl<const N: usize, T: Debug + Clone + Serialize + DeserializeOwned> Chart<N, T>
sourcepub fn notify(&self) -> Notify<N, T>
pub fn notify(&self) -> Notify<N, T>
Wait for new discoveries. Use one of the methods on the notify object to await a new discovery and get the data.
Examples
let chart = ChartBuilder::new()
.with_id(1)
.with_service_port(8042)
.local_discovery(true)
.finish()?;
let mut node_discoverd = chart.notify();
let maintain = discovery::maintain(chart.clone());
let _ = tokio::spawn(maintain); // maintain task will run forever
while chart.size() < full_size as usize {
let new = node_discoverd.recv().await.unwrap();
println!("discoverd new node: {:?}", new);
}
sourcepub fn discovery_port(&self) -> u16
pub fn discovery_port(&self) -> u16
The port this instance is using for discovery
Trait Implementations
Auto Trait Implementations
impl<const N: usize, T> !RefUnwindSafe for Chart<N, T>
impl<const N: usize, T> Send for Chart<N, T> where
T: Send,
impl<const N: usize, T> Sync for Chart<N, T> where
T: Send + Sync,
impl<const N: usize, T> Unpin for Chart<N, T> where
T: Unpin,
impl<const N: usize, T> !UnwindSafe for Chart<N, T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more