Trait ntp_daemon::spawn::BasicSpawner
source · pub trait BasicSpawner {
type Error: Error + Send;
// Required methods
fn handle_init<'life0, 'life1, 'async_trait>(
&'life0 mut self,
action_tx: &'life1 Sender<SpawnEvent>
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn handle_peer_removed<'life0, 'life1, 'async_trait>(
&'life0 mut self,
event: PeerRemovedEvent,
action_tx: &'life1 Sender<SpawnEvent>
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_id(&self) -> SpawnerId;
fn get_addr_description(&self) -> String;
fn get_description(&self) -> &str;
// Provided method
fn handle_registered<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_event: PeerCreateParameters,
_action_tx: &'life1 Sender<SpawnEvent>
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}
Required Associated Types§
Required Methods§
sourcefn handle_init<'life0, 'life1, 'async_trait>(
&'life0 mut self,
action_tx: &'life1 Sender<SpawnEvent>
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle_init<'life0, 'life1, 'async_trait>( &'life0 mut self, action_tx: &'life1 Sender<SpawnEvent> ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Handle initial spawning.
This is called on startup of the spawner and is meant to setup the initial set of peers when nothing else would have been spawned by this spawner. Once this function completes the system should be aware of at least one peer for this spawner, otherwise no events will ever be sent to the spawner and nothing will ever happen.
sourcefn handle_peer_removed<'life0, 'life1, 'async_trait>(
&'life0 mut self,
event: PeerRemovedEvent,
action_tx: &'life1 Sender<SpawnEvent>
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle_peer_removed<'life0, 'life1, 'async_trait>( &'life0 mut self, event: PeerRemovedEvent, action_tx: &'life1 Sender<SpawnEvent> ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Event handler for when a peer is removed.
This is called each time the system notifies this spawner that one of the spawned peers was removed from the system. The spawner can then add additional peers or do nothing, depending on its configuration and algorithm.
sourcefn get_addr_description(&self) -> String
fn get_addr_description(&self) -> String
Get a description of the address this spawner is connected to
sourcefn get_description(&self) -> &str
fn get_description(&self) -> &str
Get a description of the type of spawner
Provided Methods§
sourcefn handle_registered<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_event: PeerCreateParameters,
_action_tx: &'life1 Sender<SpawnEvent>
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle_registered<'life0, 'life1, 'async_trait>( &'life0 mut self, _event: PeerCreateParameters, _action_tx: &'life1 Sender<SpawnEvent> ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Event handler for when a peer is succesfully registered in the system
Every time the spawner sends a peer to the system this handler will eventually be called when the system has sucessfully registered the peer and will start polling it for ntp packets.