Skip to main content

redisctl_core/
lib.rs

1//! # redisctl-core
2//!
3//! Layer 2: Higher-level interface on top of redis-cloud and redis-enterprise clients.
4//!
5//! This crate provides:
6//! - **Unified error handling** - CoreError wrapping both platform errors
7//! - **Progress callbacks** - For Cloud's async task polling
8//! - **Module resolution** - Validate Enterprise modules before creation
9//! - **Workflows** - Multi-step operations (create + wait, etc.)
10//!
11//! ## Philosophy
12//!
13//! **Don't rebuild Layer 1. Use it and add value.**
14//!
15//! - Simple operations: Use Layer 1 directly (`redis_cloud::DatabaseHandler`, etc.)
16//! - Operations with progress: Use Layer 2 workflows
17//! - Operations with validation: Use Layer 2 helpers
18//!
19//! # Architecture
20//!
21//! ```text
22//! ┌─────────────────────────────────────────────────────────────────┐
23//! │                    Layer 3: Consumers                           │
24//! │           CLI (redisctl)        MCP (redisctl-mcp)             │
25//! └──────────────────────────┬──────────────────────────────────────┘
26//!                            │
27//!                            ▼
28//! ┌─────────────────────────────────────────────────────────────────┐
29//! │                 Layer 2: redisctl-core                          │
30//! │  - Unified errors (CoreError)                                   │
31//! │  - Progress callbacks (poll_task)                               │
32//! │  - Module resolution (resolve_modules)                          │
33//! │  - Workflows (create_and_wait, etc.)                            │
34//! └──────────────────────────┬──────────────────────────────────────┘
35//!                            │
36//!                            ▼
37//! ┌─────────────────────────────────────────────────────────────────┐
38//! │               Layer 1: Raw API Clients                          │
39//! │         redis-cloud              redis-enterprise               │
40//! └─────────────────────────────────────────────────────────────────┘
41//! ```
42//!
43//! # Example Usage
44//!
45//! ```rust,ignore
46//! use redis_cloud::{CloudClient, DatabaseHandler};
47//! use redisctl_core::{poll_task, ProgressEvent};
48//! use std::time::Duration;
49//!
50//! // Simple operation: use Layer 1 directly
51//! let handler = DatabaseHandler::new(client.clone());
52//! let databases = handler.list(subscription_id).await?;
53//!
54//! // Operation with progress: use Layer 2
55//! let task = handler.create(subscription_id, &request).await?;
56//! let completed = poll_task(
57//!     &client,
58//!     &task.task_id.unwrap(),
59//!     Duration::from_secs(600),
60//!     Duration::from_secs(10),
61//!     Some(Box::new(|event| {
62//!         if let ProgressEvent::Polling { status, elapsed, .. } = event {
63//!             println!("Status: {} ({:.0}s)", status, elapsed.as_secs());
64//!         }
65//!     })),
66//! ).await?;
67//! ```
68
69pub mod config;
70pub mod error;
71pub mod progress;
72
73pub mod cloud;
74pub mod enterprise;
75
76// Re-export commonly used items
77pub use error::{CoreError, Result};
78pub use progress::{ProgressCallback, ProgressEvent, poll_task};
79
80// Re-export config types for convenience
81pub use config::{
82    Config, ConfigError, CredentialStorage, CredentialStore, DeploymentType, Profile,
83    ProfileCredentials, ResilienceConfig,
84};
85
86// Re-export Layer 1 for convenience (but consumers can also import directly)
87pub use redis_cloud;
88pub use redis_enterprise;