1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! Kitsune2 bootstrap related types.
use crate::*;
use std::sync::Arc;
/// Method for bootstrapping WAN discovery of peers.
///
/// The internal implementation will take care of whatever polling
/// or managing of message queues is required to be notified of
/// remote peers both on initialization and over runtime.
pub trait Bootstrap: 'static + Send + Sync + std::fmt::Debug {
/// Put an agent info onto a bootstrap server.
///
/// This method takes responsibility for retrying the send operation in the case
/// of server error until such time as:
/// - the Put succeeds
/// - we receive a new info that supersedes the previous
/// - or the info expires
fn put(&self, info: Arc<AgentInfoSigned>);
}
/// Trait-object [Bootstrap].
pub type DynBootstrap = Arc<dyn Bootstrap>;
/// A factory for constructing Bootstrap instances.
pub trait BootstrapFactory: 'static + Send + Sync + std::fmt::Debug {
/// Help the builder construct a default config from the chosen
/// module factories.
fn default_config(&self, config: &mut Config) -> K2Result<()>;
/// Validate configuration.
fn validate_config(&self, config: &Config) -> K2Result<()>;
/// Construct a bootstrap instance.
fn create(
&self,
builder: Arc<Builder>,
peer_store: DynPeerStore,
space_id: SpaceId,
) -> BoxFut<'static, K2Result<DynBootstrap>>;
}
/// Trait-object [BootstrapFactory].
pub type DynBootstrapFactory = Arc<dyn BootstrapFactory>;