eshanized_polaris/
lib.rs

1//! # Polaris
2//!
3//! Rust-native distributed compute and orchestration framework for scaling concurrent workloads
4//! across threads, processes, or machines.
5//!
6//! ## Quick Start
7//!
8//! ```rust,no_run
9//! use polaris::prelude::*;
10//!
11//! #[polaris::task]
12//! async fn compute_square(x: i32) -> PolarisResult<i32> {
13//!     Ok(x * x)
14//! }
15//!
16//! #[tokio::main]
17//! async fn main() -> PolarisResult<()> {
18//!     // Create a local cluster for development
19//!     let cluster = Cluster::builder()
20//!         .with_local_node()
21//!         .build()
22//!         .await?;
23//!     
24//!     // Submit a task
25//!     let task = Task::new("compute", bytes::Bytes::from("5"));
26//!     let handle = cluster.submit(task).await?;
27//!     
28//!     // Wait for result
29//!     let result = handle.result().await?;
30//!     println!("Result: {:?}", result);
31//!     
32//!     Ok(())
33//! }
34//! ```
35//!
36//! ## Features
37//!
38//! - **Distributed Task Execution**: Schedule and execute tasks across a cluster
39//! - **Intelligent Scheduling**: Pluggable schedulers (RoundRobin, LoadAware, custom)
40//! - **Fault Tolerance**: Automatic retries with exponential backoff
41//! - **Security**: mTLS by default, optional JWT authentication
42//! - **Observability**: Built-in tracing and Prometheus metrics
43//! - **Flexible Storage**: In-memory, RocksDB, or Sled backends
44//! - **DAG Support**: Define complex task dependencies
45//!
46//! ## Architecture
47//!
48//! Polaris follows a modular architecture:
49//!
50//! - **Cluster**: Top-level orchestration API
51//! - **Scheduler**: Pluggable task scheduling strategies
52//! - **Node**: Worker nodes that execute tasks
53//! - **Transport**: Network layer (QUIC, TLS, gRPC)
54//! - **Storage**: Persistent state backends
55//!
56//! ## Examples
57//!
58//! ### Connect to a Cluster
59//!
60//! ```rust,no_run
61//! use polaris::prelude::*;
62//!
63//! # async fn example() -> PolarisResult<()> {
64//! let cluster = Cluster::connect(["10.0.0.1:7001", "10.0.0.2:7001"]).await?;
65//! # Ok(())
66//! # }
67//! ```
68//!
69//! ### Submit Tasks with Retry
70//!
71//! ```rust,no_run
72//! use polaris::prelude::*;
73//! use std::time::Duration;
74//!
75//! # async fn example(cluster: Cluster) -> PolarisResult<()> {
76//! let task = Task::new("my_task", bytes::Bytes::from("input"))
77//!     .with_priority(TaskPriority::High)
78//!     .with_timeout(Duration::from_secs(60))
79//!     .with_max_retries(5);
80//!
81//! let handle = cluster.submit(task).await?;
82//! # Ok(())
83//! # }
84//! ```
85//!
86//! ### Custom Scheduler
87//!
88//! ```rust,no_run
89//! use polaris::prelude::*;
90//!
91//! # async fn example() -> PolarisResult<()> {
92//! let cluster = Cluster::builder()
93//!     .with_scheduler(LoadAwareScheduler::new())
94//!     .with_local_node()
95//!     .build()
96//!     .await?;
97//! # Ok(())
98//! # }
99//! ```
100
101#![forbid(unsafe_code)]
102#![warn(missing_docs, rust_2018_idioms)]
103#![cfg_attr(docsrs, feature(doc_cfg))]
104
105// Re-export core types
106pub use eshanized_polaris_core::{
107    cluster::{Cluster, ClusterBuilder, ClusterStats},
108    config::{
109        ClusterConfig, NetworkConfig, NodeConfig, ResourceLimits, SchedulerConfig, SecurityConfig,
110        StorageConfig,
111    },
112    dag::DagExecutor,
113    errors::{PolarisError, PolarisResult},
114    node::{Node, NodeId, NodeInfo, NodeRegistry, NodeStatus, ResourceUsage},
115    observability::{init_tracing, MetricsCollector},
116    scheduler::{LoadAwareScheduler, RoundRobinScheduler, Scheduler},
117    serialization::default_serializer,
118    storage::{InMemoryStorage, Storage},
119    task::{Task, TaskHandle, TaskId, TaskMetadata, TaskPriority, TaskResult, TaskStatus},
120};
121
122// Re-export macros
123pub use eshanized_polaris_macros::task;
124
125/// Convenient prelude for common imports
126pub mod prelude {
127    //! Prelude module with commonly used types and traits.
128    //!
129    //! # Example
130    //!
131    //! ```rust
132    //! use polaris::prelude::*;
133    //! ```
134
135    pub use crate::{
136        task, Cluster, ClusterBuilder, ClusterConfig, DagExecutor, LoadAwareScheduler, Node,
137        NodeConfig, NodeId, NodeInfo, NodeStatus, PolarisError, PolarisResult,
138        RoundRobinScheduler, Scheduler, Task, TaskHandle, TaskId, TaskPriority, TaskStatus,
139    };
140
141    pub use std::time::Duration;
142}
143
144#[cfg(test)]
145mod tests {
146    use super::prelude::*;
147
148    #[test]
149    fn test_prelude_imports() {
150        // Verify that all prelude types are accessible
151        let _result: PolarisResult<()> = Ok(());
152        let _id = TaskId::new();
153    }
154}