server/lib.rs
1//! # Quetty Server Library
2//!
3//! Core server-side functionality for the Quetty Azure Service Bus terminal application.
4//! This crate provides comprehensive Azure Service Bus integration, authentication,
5//! message processing, and bulk operations capabilities.
6//!
7//! ## Architecture Overview
8//!
9//! The server library is organized into several key modules:
10//!
11//! - **[`auth`]** - Authentication system supporting Azure AD and connection strings
12//! - **[`service_bus_manager`]** - Core Service Bus operations and management
13//! - **[`producer`]** and **[`consumer`]** - Message production and consumption
14//! - **[`bulk_operations`]** - Efficient bulk message processing
15//! - **[`model`]** - Data models and message representations
16//! - **[`taskpool`]** - Thread pool management for concurrent operations
17//! - **[`utils`]** - Utility functions and helpers
18//!
19//! ## Key Features
20//!
21//! ### Multi-Modal Authentication
22//! - **Azure Active Directory** - Device Code Flow and Client Credentials
23//! - **Connection Strings** - SAS token-based authentication
24//! - **Token Management** - Automatic refresh and caching
25//!
26//! ### High-Performance Message Processing
27//! - **Concurrent Operations** - Multi-threaded message processing
28//! - **Bulk Operations** - Efficient batch send/delete operations
29//! - **Resource Management** - Automatic connection pooling and cleanup
30//!
31//! ### Azure Integration
32//! - **Management API** - Namespace and queue discovery
33//! - **Service Bus Operations** - Send, receive, peek, delete messages
34//! - **Queue Statistics** - Real-time metrics and monitoring
35//!
36//! ## Quick Start
37//!
38//! ### Basic Service Bus Operations
39//! ```no_run
40//! use quetty_server::service_bus_manager::ServiceBusManager;
41//! use quetty_server::auth::ConnectionStringProvider;
42//!
43//! #[tokio::main]
44//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
45//! // Initialize authentication
46//! let auth_provider = ConnectionStringProvider::new(connection_config)?;
47//!
48//! // Create Service Bus manager
49//! let manager = ServiceBusManager::new(auth_provider).await?;
50//!
51//! // Send a message
52//! let message_id = manager.send_message(
53//! "my-queue",
54//! "Hello, Service Bus!".to_string(),
55//! None
56//! ).await?;
57//!
58//! println!("Message sent with ID: {}", message_id);
59//! Ok(())
60//! }
61//! ```
62//!
63//! ### Bulk Operations
64//! ```no_run
65//! use quetty_server::bulk_operations::BulkOperationHandler;
66//! use quetty_server::service_bus_manager::ServiceBusManager;
67//!
68//! #[tokio::main]
69//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
70//! let manager = ServiceBusManager::new(auth_provider).await?;
71//! let bulk_handler = BulkOperationHandler::new(manager);
72//!
73//! // Bulk send messages
74//! let messages = vec![
75//! "Message 1".to_string(),
76//! "Message 2".to_string(),
77//! "Message 3".to_string(),
78//! ];
79//!
80//! let results = bulk_handler.bulk_send("my-queue", messages).await?;
81//! println!("Sent {} messages", results.len());
82//! Ok(())
83//! }
84//! ```
85//!
86//! ### Authentication with Azure AD
87//! ```no_run
88//! use quetty_server::auth::{AzureAdProvider, AuthStateManager};
89//! use std::sync::Arc;
90//!
91//! #[tokio::main]
92//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
93//! // Initialize Azure AD authentication
94//! let auth_state = Arc::new(AuthStateManager::new());
95//! let azure_provider = AzureAdProvider::new(azure_config, http_client)?;
96//!
97//! // Authenticate and get token
98//! let token = azure_provider.authenticate().await?;
99//! println!("Authenticated successfully");
100//! Ok(())
101//! }
102//! ```
103//!
104//! ## Integration with UI
105//!
106//! This server library is designed to work seamlessly with the Quetty UI:
107//!
108//! - **Shared Authentication State** - Synchronized auth across UI and server
109//! - **Async Operations** - Non-blocking operations for responsive UI
110//! - **Error Propagation** - Structured error handling for UI feedback
111//! - **Progress Reporting** - Real-time operation progress for bulk operations
112//!
113//! ## Performance Considerations
114//!
115//! - **Connection Pooling** - Efficient Service Bus client management
116//! - **Concurrent Operations** - Parallel processing where possible
117//! - **Memory Management** - Careful resource cleanup and disposal
118//! - **Batch Processing** - Optimized bulk operations for large datasets
119//!
120//! ## Error Handling
121//!
122//! The library provides comprehensive error handling with detailed error types:
123//!
124//! - **Authentication Errors** - Token issues, expired credentials
125//! - **Service Bus Errors** - Network issues, quota exceeded, invalid operations
126//! - **Validation Errors** - Input validation and constraint violations
127//! - **Resource Errors** - Connection failures, timeout issues
128
129pub mod auth;
130pub mod bulk_operations;
131pub mod common;
132pub mod consumer;
133pub mod encryption;
134pub mod model;
135pub mod producer;
136pub mod service_bus_manager;
137pub mod taskpool;
138pub mod utils;