scepter 0.1.5

Composable primitives for planet-scale time-series routing, indexing, and aggregation.
Documentation
/// Sliding admission window used to reject old deltas and finalize old buckets.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct AdmissionWindow {
    length: u64,
}

impl AdmissionWindow {
    /// Creates an admission window with `length` timestamp units.
    pub fn new(length: u64) -> Self {
        Self { length }
    }

    /// Returns the length of the admission window.
    pub fn length(self) -> u64 {
        self.length
    }

    pub(super) fn cutoff(self, watermark: u64) -> u64 {
        watermark.saturating_sub(self.length)
    }
}

/// One delta written by a target for collection aggregation.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DeltaPoint<K, V> {
    /// Aggregation key, such as `(cluster, user, metric)`.
    pub key: K,
    /// Delta end timestamp. The point is assigned to a bucket by this value.
    pub end_time: u64,
    /// Delta value to aggregate.
    pub value: V,
}

/// An immutable bucket emitted by a `BucketedAggregator`.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct FinalizedBucket<K, V> {
    /// Aggregation key.
    pub key: K,
    /// Inclusive bucket start timestamp.
    pub start: u64,
    /// Exclusive bucket end timestamp.
    pub end: u64,
    /// Aggregated value for this key and time bucket.
    pub value: V,
}