rigatoni_stores/
lib.rs

1// Copyright 2025 Rigatoni Contributors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// SPDX-License-Identifier: Apache-2.0
16
17//! State store implementations for Rigatoni ETL framework.
18//!
19//! This crate provides various backend implementations of the
20//! [`StateStore`](rigatoni_core::state::StateStore) trait for persisting
21//! `MongoDB` change stream resume tokens.
22//!
23//! # Available Stores
24//!
25//! - **Memory** (`memory` feature, enabled by default): In-memory state storage
26//! - **Redis** (`redis-store` feature): Distributed state storage with Redis
27//! - **File** (`file` feature, coming soon): File-based state storage
28//!
29//! # Feature Flags
30//!
31//! - `memory`: In-memory state store (enabled by default)
32//! - `redis-store`: Redis-backed state store (requires Redis server)
33//! - `file`: File-based state store (coming soon)
34//! - `all-stores`: Enable all available stores
35//!
36//! # Example: In-Memory Store
37//!
38//! ```rust
39//! use rigatoni_stores::memory::MemoryStore;
40//! use rigatoni_core::state::StateStore;
41//! use mongodb::bson::doc;
42//!
43//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
44//! // Create in-memory store (no configuration needed)
45//! let store = MemoryStore::new();
46//!
47//! // Save resume token
48//! let token = doc! { "_data": "token123" };
49//! store.save_resume_token("users", &token).await?;
50//!
51//! // Retrieve token
52//! let retrieved = store.get_resume_token("users").await?;
53//! assert!(retrieved.is_some());
54//! # Ok(())
55//! # }
56//! ```
57//!
58//! # Example: Redis Store
59//!
60//! ```rust,ignore
61//! use rigatoni_stores::redis::{RedisStore, RedisConfig};
62//! use rigatoni_core::state::StateStore;
63//! use mongodb::bson::doc;
64//!
65//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
66//! // Configure Redis connection
67//! let config = RedisConfig::builder()
68//!     .url("redis://localhost:6379")
69//!     .pool_size(10)
70//!     .build()?;
71//!
72//! // Create store
73//! let store = RedisStore::new(config).await?;
74//!
75//! // Save resume token
76//! let token = doc! { "_data": "token123" };
77//! store.save_resume_token("users", &token).await?;
78//!
79//! // Retrieve token
80//! let retrieved = store.get_resume_token("users").await?;
81//! assert!(retrieved.is_some());
82//! # Ok(())
83//! # }
84//! ```
85
86#![warn(missing_docs)]
87#![warn(clippy::all)]
88#![warn(clippy::pedantic)]
89
90#[cfg(feature = "memory")]
91pub mod memory;
92
93#[cfg(feature = "redis-store")]
94pub mod redis;