pub struct MergeConfig { /* private fields */ }Expand description
Merge strategies run periodically in the background and attempt to merge split clusters by joining peers in DHT records and message hashes for bubble detection and merging, and by joining peers in DHT records with overlapping message hashes for message overlap detection and merging.
Implementations§
Source§impl MergeConfig
impl MergeConfig
Sourcepub fn builder() -> MergeConfigBuilder
pub fn builder() -> MergeConfigBuilder
Create a new MergeConfigBuilder with default values.
Examples found in repository?
examples/without_mergers.rs (line 43)
13async fn main() -> Result<()> {
14 // Generate a new random secret key
15 let secret_key = SecretKey::generate();
16 let signing_key = SigningKey::from_bytes(&secret_key.to_bytes());
17
18 // Set up endpoint with discovery enabled
19 let endpoint = Endpoint::builder(iroh::endpoint::presets::N0)
20 .secret_key(secret_key.clone())
21 .bind()
22 .await?;
23
24 // Initialize gossip with auto-discovery
25 let gossip = Gossip::builder().spawn(endpoint.clone());
26
27 // Set up protocol router
28 let _router = iroh::protocol::Router::builder(endpoint.clone())
29 .accept(iroh_gossip::ALPN, gossip.clone())
30 .spawn();
31
32 let topic_id = TopicId::new("my-iroh-gossip-topic".to_string());
33 let initial_secret = b"my-initial-secret".to_vec();
34
35 let record_publisher = RecordPublisher::new(
36 topic_id.clone(),
37 signing_key.clone(),
38 None,
39 initial_secret,
40 // [!] Disable merge workers (BubbleMerge and MessageOverlapMerge)
41 Config::builder()
42 .merge_config(
43 MergeConfig::builder()
44 .bubble_merge(BubbleMergeConfig::Disabled)
45 .message_overlap_merge(MessageOverlapMergeConfig::Disabled)
46 .build(),
47 )
48 .build(),
49 );
50
51 let topic = gossip
52 .subscribe_and_join_with_auto_discovery(record_publisher)
53 .await?;
54
55 println!("[joined topic]");
56
57 // Do something with the gossip topic
58 // (bonus: GossipSender and GossipReceiver are safely clonable)
59 let (_gossip_sender, _gossip_receiver) = topic.split().await?;
60
61 Ok(())
62}More examples
examples/full_config.rs (line 48)
17fn config_builder() -> Config {
18 Config::builder()
19 .dht_config(
20 DhtConfig::builder()
21 .retries(3)
22 .base_retry_interval(Duration::from_secs(5))
23 .max_retry_jitter(Duration::from_secs(10))
24 .get_timeout(Duration::from_secs(10))
25 .put_timeout(Duration::from_secs(10))
26 .build(),
27 )
28 .bootstrap_config(
29 BootstrapConfig::builder()
30 .max_bootstrap_records(5)
31 .publish_record_on_startup(true)
32 .check_older_records_first_on_startup(false)
33 .discovery_poll_interval(Duration::from_millis(2000))
34 .no_peers_retry_interval(Duration::from_millis(1500))
35 .per_peer_join_settle_time(Duration::from_millis(100))
36 .join_confirmation_wait_time(Duration::from_millis(500))
37 .build(),
38 )
39 .max_join_peer_count(4)
40 .publisher_config(
41 PublisherConfig::builder()
42 .initial_delay(Duration::from_secs(10))
43 .base_interval(Duration::from_secs(10))
44 .max_jitter(Duration::from_secs(50))
45 .build(),
46 )
47 .merge_config(
48 MergeConfig::builder()
49 .bubble_merge(
50 BubbleMergeConfig::builder()
51 .min_neighbors(4)
52 .base_interval(Duration::from_secs(60))
53 .max_jitter(Duration::from_secs(120))
54 .fail_topic_creation_on_merge_startup_failure(true)
55 .build(),
56 )
57 .message_overlap_merge(
58 MessageOverlapMergeConfig::builder()
59 .base_interval(Duration::from_secs(60))
60 .max_jitter(Duration::from_secs(120))
61 .fail_topic_creation_on_merge_startup_failure(true)
62 .build(),
63 )
64 .build(),
65 )
66 .timeouts(
67 TimeoutConfig::builder()
68 .join_peer_timeout(Duration::from_secs(5))
69 .broadcast_neighbors_timeout(Duration::from_secs(5))
70 .broadcast_timeout(Duration::from_secs(5))
71 .build(),
72 )
73 .build()
74}Sourcepub fn bubble_merge(&self) -> &BubbleMergeConfig
pub fn bubble_merge(&self) -> &BubbleMergeConfig
Bubble merge strategy config.
Default: BubbleMergeConfig::default()
Sourcepub fn message_overlap_merge(&self) -> &MessageOverlapMergeConfig
pub fn message_overlap_merge(&self) -> &MessageOverlapMergeConfig
Message overlap merge strategy config.
Default: MessageOverlapMergeConfig::default()
Trait Implementations§
Source§impl Clone for MergeConfig
impl Clone for MergeConfig
Source§fn clone(&self) -> MergeConfig
fn clone(&self) -> MergeConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MergeConfig
impl Debug for MergeConfig
Source§impl Default for MergeConfig
impl Default for MergeConfig
Source§fn default() -> MergeConfig
fn default() -> MergeConfig
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MergeConfig
impl RefUnwindSafe for MergeConfig
impl Send for MergeConfig
impl Sync for MergeConfig
impl Unpin for MergeConfig
impl UnsafeUnpin for MergeConfig
impl UnwindSafe for MergeConfig
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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