Skip to main content

tape_sdk/
read_options.rs

1//! Client-level knobs for the read paths.
2
3use tape_core::share::ShareToken;
4
5/// Peers asked at once before a metadata query widens.
6pub const DEFAULT_QUERY_FAN_OUT: usize = 3;
7
8/// Read pacing knobs and the share token for hidden tracks; defaults are the tuned fast path.
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub struct ReadOptions {
11    /// In-flight slice downloads per track read. Anything above `k` is a hedge
12    /// against a slow node; below `k` splits one wave into several.
13    pub slice_concurrency: usize,
14
15    /// Peers a metadata query asks before widening. Tooling that wants the old
16    /// full race can raise this past the committee size.
17    pub query_fan_out: usize,
18
19    /// Share token presented to nodes on slice and track-data fetches.
20    pub share_token: Option<ShareToken>,
21}
22
23impl Default for ReadOptions {
24    fn default() -> Self {
25        Self {
26            slice_concurrency: 8,
27            query_fan_out: DEFAULT_QUERY_FAN_OUT,
28            share_token: None,
29        }
30    }
31}
32
33#[cfg(test)]
34mod tests {
35    use super::*;
36
37    #[test]
38    fn defaults() {
39        let options = ReadOptions::default();
40        assert_eq!(options.slice_concurrency, 8);
41        assert_eq!(options.query_fan_out, DEFAULT_QUERY_FAN_OUT);
42        assert!(options.share_token.is_none());
43    }
44}