pub struct Cluster<D = NeuralPlant>{ /* private fields */ }
Expand description
A cluster represents a local subnet of connected runtimes
Implementations§
Source§impl<D> Cluster<D>
impl<D> Cluster<D>
Sourcepub fn new(
local_key: &Keypair,
event_tx: Sender<SubnetEvent>,
cmd_rx: Receiver<SubnetCommand>,
power_rx: Receiver<Power>,
) -> Result<Self>
pub fn new( local_key: &Keypair, event_tx: Sender<SubnetEvent>, cmd_rx: Receiver<SubnetCommand>, power_rx: Receiver<Power>, ) -> Result<Self>
Create a new cluster
pub fn with_runtime(self, runtime: Runtime<D>) -> Self
Sourcepub const fn learned_patterns(&self) -> &HashMap<String, Pattern>
pub const fn learned_patterns(&self) -> &HashMap<String, Pattern>
returns an immutable reference to the learned patterns
Sourcepub fn learned_patterns_mut(&mut self) -> &mut HashMap<String, Pattern>
pub fn learned_patterns_mut(&mut self) -> &mut HashMap<String, Pattern>
returns a mutable reference to the learned patterns
Sourcepub fn runtime_mut(&mut self) -> &mut Runtime<D>
pub fn runtime_mut(&mut self) -> &mut Runtime<D>
returns a mutable reference to the runtime
Sourcepub const fn swarm(&self) -> &Swarm<SubnetBehaviour>
pub const fn swarm(&self) -> &Swarm<SubnetBehaviour>
returns an immutable reference to the swarm
Sourcepub const fn task_peers(&self) -> &HashMap<String, Vec<PeerId>>
pub const fn task_peers(&self) -> &HashMap<String, Vec<PeerId>>
returns an immutable reference to the task peers
Sourcepub fn peer_id(&self) -> PeerId
pub fn peer_id(&self) -> PeerId
returns a copy of the current peer id associated with the cluster
Sourcepub async fn get_capable_peers<T>(&self, filter: T) -> Vec<(PeerId, PeerInfo)>where
T: ToString,
pub async fn get_capable_peers<T>(&self, filter: T) -> Vec<(PeerId, PeerInfo)>where
T: ToString,
returns a list of peers that are equipped with a particular capability
Sourcepub async fn get_capable_peer_ids<T>(&self, filter: T) -> Vec<PeerId>where
T: ToString,
pub async fn get_capable_peer_ids<T>(&self, filter: T) -> Vec<PeerId>where
T: ToString,
get a list os peer ids for peers equipped with a particular capbility
Sourcepub async fn run(self) -> Result<()>where
D: TriadDriver,
pub async fn run(self) -> Result<()>where
D: TriadDriver,
the loop for the cluster
Sourcepub async fn allocate_task(
&self,
task_type: &str,
work_units: Vec<WorkUnit>,
) -> Result<(), NetworkError>
pub async fn allocate_task( &self, task_type: &str, work_units: Vec<WorkUnit>, ) -> Result<(), NetworkError>
Allocate a task across the network based on resources
Sourcepub async fn learn_network_patterns(&mut self) -> Result<(), NetworkError>
pub async fn learn_network_patterns(&mut self) -> Result<(), NetworkError>
Learn patterns from the network
Sourcepub async fn distribute_surface_patterns(&self) -> Result<(), NetworkError>
pub async fn distribute_surface_patterns(&self) -> Result<(), NetworkError>
Distribute surface patterns across the subnet
Sourcepub async fn form_processing_cluster(
&mut self,
task_type: &str,
) -> Result<Vec<PeerId>, NetworkError>
pub async fn form_processing_cluster( &mut self, task_type: &str, ) -> Result<Vec<PeerId>, NetworkError>
Form a dynamic cluster for processing tasks
Sourcepub async fn synchronize_memory(&self) -> Result<(), NetworkError>
pub async fn synchronize_memory(&self) -> Result<(), NetworkError>
Synchronize topological memory across the cluster
Sourcepub async fn dynamic_work_distribution(
&mut self,
operations: Vec<(EdgeId, Vec<LPR>)>,
) -> Result<(), NetworkError>where
D: TriadDriver,
pub async fn dynamic_work_distribution(
&mut self,
operations: Vec<(EdgeId, Vec<LPR>)>,
) -> Result<(), NetworkError>where
D: TriadDriver,
Create a dynamic work distribution for a set of VNode operations
Sourcepub async fn topology_aware_learning(&self) -> Result<(), NetworkError>
pub async fn topology_aware_learning(&self) -> Result<(), NetworkError>
Create a topology-aware work distribution for learning tasks
Auto Trait Implementations§
impl<D = Plant> !Freeze for Cluster<D>
impl<D = Plant> !RefUnwindSafe for Cluster<D>
impl<D> Send for Cluster<D>
impl<D = Plant> !Sync for Cluster<D>
impl<D> Unpin for Cluster<D>
impl<D = Plant> !UnwindSafe for Cluster<D>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more