rusty_ssr/lib.rs
1//! # Rusty SSR
2//!
3//! High-performance Server-Side Rendering engine for Rust with V8 isolate pool
4//! and multi-tier CPU-optimized caching.
5//!
6//! ## Features
7//!
8//! - **V8 Isolate Pool**: Thread pool with dedicated V8 isolates for parallel SSR
9//! - **Multi-tier Cache**: L1/L2 CPU cache (hot) + RAM (cold) with LRU eviction
10//! - **Axum Integration**: Ready-to-use middleware for Axum web framework
11//! - **Brotli Compression**: Static and dynamic Brotli compression
12//!
13//! ## Quick Start
14//!
15//! ```rust,ignore
16//! use rusty_ssr::prelude::*;
17//!
18//! #[tokio::main]
19//! async fn main() {
20//! // Initialize the SSR engine
21//! let engine = SsrEngine::builder()
22//! .bundle_path("ssr-bundle.js")
23//! .pool_size(num_cpus::get())
24//! .cache_size(300)
25//! .build_engine()
26//! .expect("Failed to create SSR engine");
27//!
28//! // Render a page
29//! let html = engine.render("/home").await.unwrap();
30//! println!("{}", html);
31//! }
32//! ```
33//!
34//! ## Architecture
35//!
36//! ```text
37//! Request → SSR Cache (L1 hot → L2 cold) → V8 Pool → Response
38//! ↑ ↓
39//! └──────── cache result ──────┘
40//! ```
41//!
42//! ## Performance
43//!
44//! - **73,000+ req/s** with caching enabled
45//! - **Sub-millisecond** cache hit latency (~0.2ms)
46//! - **10-15x faster** than Node.js SSR solutions
47
48#![warn(missing_docs)]
49#![warn(rustdoc::missing_crate_level_docs)]
50
51// Re-export commonly used types
52pub use config::{SsrConfig, SsrConfigBuilder};
53pub use engine::SsrEngine;
54pub use error::{SsrError, SsrResult};
55
56/// Configuration types and builder
57pub mod config;
58
59/// Main SSR engine
60pub mod engine;
61
62/// Error types
63pub mod error;
64
65/// V8 thread pool for parallel rendering
66#[cfg(feature = "v8-pool")]
67pub mod v8_pool;
68
69/// Multi-tier caching system
70#[cfg(feature = "cache")]
71pub mod cache;
72
73/// Axum middleware (brotli, etc.)
74#[cfg(feature = "axum-integration")]
75pub mod middleware;
76
77/// Prelude module for convenient imports
78pub mod prelude {
79 //! Convenient re-exports for common usage
80 //!
81 //! ```rust
82 //! use rusty_ssr::prelude::*;
83 //! ```
84
85 pub use crate::config::{SsrConfig, SsrConfigBuilder};
86 pub use crate::engine::SsrEngine;
87 pub use crate::error::{SsrError, SsrResult};
88
89 #[cfg(feature = "cache")]
90 pub use crate::cache::{SsrCache, CacheMetrics};
91
92 #[cfg(feature = "v8-pool")]
93 pub use crate::v8_pool::{V8Pool, V8PoolConfig};
94}