Skip to main content

prom_mock_rs/
lib.rs

1//! # Prometheus Mock Library
2//!
3//! A library for creating mock Prometheus HTTP API servers for integration testing.
4//!
5//! This library provides components for:
6//! - **Fixture-based API Mock**: Returns predefined responses from YAML fixtures
7//! - **Remote Write Sink**: Accepts remote write data and stores it in memory for querying
8//! - **Label Matching**: Extensible label filtering for time series queries
9//! - **In-Memory Storage**: Fast storage backend for metrics data
10//!
11//! # Examples
12//!
13//! ```no_run
14//! use std::sync::Arc;
15//! use prom_mock_rs::{MemoryStorage, SimpleQueryEngine, http::build_router};
16//!
17//! # async fn example() -> std::io::Result<()> {
18//! // Create storage and query engine
19//! let storage = Arc::new(MemoryStorage::new());
20//! let engine = SimpleQueryEngine::new(storage.clone());
21//!
22//! // Build HTTP router with state
23//! let state = prom_mock_rs::http::AppState::builder()
24//!     .with_storage(storage)
25//!     .build()?;
26//! let app = build_router(state);
27//! # Ok(())
28//! # }
29//! ```
30
31pub mod fixtures;
32pub mod http;
33pub mod matchers;
34pub mod query_engine;
35pub mod storage;
36pub mod timeutil;
37
38// Re-export commonly used types for convenience
39pub use fixtures::FixtureBook;
40pub use matchers::{EqualMatcher, LabelMatcher, NotEqualMatcher, NotRegexMatcher, RegexMatcher};
41pub use query_engine::SimpleQueryEngine;
42pub use storage::{Label, MemoryStorage, Sample, Storage, TimeSeries};