athena_rs 3.3.0

Database gateway API
Documentation
//! Optional `X-Athena-Insert-Window` header: per-request execution window in milliseconds for gateway insert batching.

use actix_web::HttpRequest;

const HEADER: &str = "x-athena-insert-window";

/// Parses `X-Athena-Insert-Window` as a positive millisecond duration, capped for safety.
pub fn x_athena_insert_window_ms(req: &HttpRequest) -> Option<u64> {
    let raw = req
        .headers()
        .get(HEADER)
        .and_then(|v| v.to_str().ok())
        .map(str::trim)
        .filter(|s| !s.is_empty())?;
    let n: u64 = raw.parse().ok()?;
    if n == 0 {
        return None;
    }
    Some(n.min(60_000))
}