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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//! Pluggable seeds providers.
//!
//! A seeds provider hands the gossip task an up-to-date list of
//! peers in the canonical
//! `host:port:rack:dc:tokens|host:port:rack:dc:tokens` format.
//! Three implementations ship with the engine:
//!
//! * [`simple::SimpleSeedsProvider`] - returns the seeds parsed
//! from the YAML config.
//! * [`dns::DnsSeedsProvider`] - resolves a configured DNS
//! hostname to a list of IPs (mirroring the reference
//! `dns_get_seeds`, with the resolver factored behind a trait so
//! the unit test can substitute a deterministic implementation).
//! * [`florida::FloridaSeedsProvider`] - HTTP GET to a Florida
//! service, parses the body. Hand-rolled HTTP/1.0 client over
//! `tokio::net::TcpStream` to stay within the locked dependency
//! set.
//!
//! The trait shape is the seam Stage 13 will expose through the
//! embedding API; this stage locks the surface so the embed
//! wrapper only needs to forward.
//!
//! # Examples
//!
//! ```
//! use dynomite::seeds::{SeedsProvider, simple::SimpleSeedsProvider};
//! use dynomite::conf::ConfDynSeed;
//! let seeds = vec![ConfDynSeed::parse("h1:8101:rA:dc1:1").unwrap()];
//! let p = SimpleSeedsProvider::new(seeds);
//! let got = p.get_seeds().unwrap();
//! assert_eq!(got.len(), 1);
//! ```
use io;
use Error;
use crateConfDynSeed;
/// Error type for seeds providers.
/// Pluggable seeds provider.
///
/// Implementations may block; the gossip task calls them from a
/// dedicated tokio task with timeouts wrapped at the call site.
/// `SeedsProvider` is an async trait emulated via an associated
/// future type so it can be implemented for both blocking
/// (`SimpleSeedsProvider`) and async (`FloridaSeedsProvider`)
/// shapes.
/// Marker trait used by Stage 13 to register custom seeds
/// providers through the embedding API. Implementing
/// [`SeedsProvider`] is sufficient.