ringkernel_ecosystem/
lib.rs

1//! Ecosystem integrations for RingKernel.
2//!
3//! This crate provides optional integrations with popular Rust ecosystem
4//! libraries for actors, web frameworks, data processing, and observability.
5//!
6//! # Feature Flags
7//!
8//! All integrations are opt-in via feature flags:
9//!
10//! - `actix` - Actix actor framework bridge
11//! - `tower` - Tower service middleware integration
12//! - `axum` - Axum web framework integration
13//! - `arrow` - Apache Arrow data processing
14//! - `polars` - Polars DataFrame operations
15//! - `grpc` - gRPC server via Tonic
16//! - `candle` - Candle ML framework bridge
17//! - `config` - Configuration file management
18//! - `tracing-integration` - Enhanced tracing support
19//! - `prometheus` - Prometheus metrics export
20//! - `full` - All integrations enabled
21//!
22//! # Example
23//!
24//! ```toml
25//! [dependencies]
26//! ringkernel-ecosystem = { version = "0.1", features = ["axum", "prometheus"] }
27//! ```
28
29#![warn(missing_docs)]
30#![warn(clippy::all)]
31
32pub mod error;
33
34#[cfg(feature = "persistent")]
35pub mod persistent;
36
37#[cfg(feature = "persistent-cuda")]
38pub mod cuda_bridge;
39
40#[cfg(feature = "persistent-wgpu")]
41pub mod wgpu_bridge;
42
43#[cfg(feature = "actix")]
44pub mod actix;
45
46#[cfg(feature = "tower")]
47pub mod tower;
48
49#[cfg(feature = "axum")]
50pub mod axum;
51
52#[cfg(feature = "arrow")]
53pub mod arrow;
54
55#[cfg(feature = "polars")]
56pub mod polars;
57
58#[cfg(feature = "grpc")]
59pub mod grpc;
60
61#[cfg(feature = "candle")]
62pub mod candle;
63
64#[cfg(feature = "config")]
65pub mod config;
66
67#[cfg(feature = "tracing-integration")]
68pub mod tracing_ext;
69
70#[cfg(feature = "prometheus")]
71pub mod metrics;
72
73#[cfg(feature = "graphql")]
74pub mod graphql;
75
76#[cfg(feature = "enterprise")]
77pub mod enterprise;
78
79#[cfg(feature = "ml-bridge")]
80pub mod ml_bridge;
81
82/// Prelude for convenient imports.
83///
84/// Note: Each integration module defines its own `RuntimeHandle` trait with
85/// different bounds. To avoid conflicts, import the specific `RuntimeHandle`
86/// from the module you're using (e.g., `use ringkernel_ecosystem::axum::RuntimeHandle`).
87pub mod prelude {
88    pub use crate::error::*;
89
90    #[cfg(feature = "persistent")]
91    pub use crate::persistent::*;
92
93    // Re-export commonly used types, excluding RuntimeHandle to avoid conflicts
94    #[cfg(feature = "actix")]
95    pub use crate::actix::{
96        BridgeHealth, GpuActorBridge, GpuActorConfig, GpuActorExt, GpuRequest, GpuResponse,
97        HealthCheck, TypedGpuRequest,
98    };
99    #[cfg(all(feature = "actix", feature = "persistent"))]
100    pub use crate::actix::{
101        GetStatsCmd, GpuPersistentActor, GpuPersistentActorExt, InjectCmd, PauseCmd,
102        PersistentActorConfig, PersistentResponseMsg, ResumeCmd, RunStepsCmd, ShutdownCmd,
103        Subscribe, Unsubscribe,
104    };
105
106    #[cfg(all(feature = "tower", feature = "persistent"))]
107    pub use crate::tower::{
108        PersistentKernelLayer, PersistentKernelService, PersistentServiceBuilder,
109        PersistentServiceConfig, PersistentServiceRequest, PersistentServiceResponse,
110    };
111    #[cfg(feature = "tower")]
112    pub use crate::tower::{
113        RingKernelLayer, RingKernelService, ServiceBuilder, ServiceConfig, ServiceRequest,
114        ServiceResponse,
115    };
116
117    #[cfg(feature = "axum")]
118    pub use crate::axum::{
119        gpu_handler, health_handler, ApiRequest, ApiResponse, AppState, AxumConfig, HealthResponse,
120        KernelHealth, RequestStats, RouterBuilder, StatsSnapshot,
121    };
122    #[cfg(all(feature = "axum", feature = "persistent"))]
123    pub use crate::axum::{
124        impulse_handler, pause_handler, persistent_health_handler, persistent_stats_handler,
125        resume_handler, step_handler, CommandResponse, ImpulseRequest, PersistentAxumConfig,
126        PersistentGpuState, PersistentHealthResponse, PersistentStatsResponse, StepRequest,
127    };
128
129    #[cfg(feature = "persistent-cuda")]
130    pub use crate::cuda_bridge::{CudaPersistentHandle, CudaPersistentHandleBuilder};
131
132    #[cfg(feature = "persistent-wgpu")]
133    pub use crate::wgpu_bridge::{
134        BatchDispatchStats, BatchDispatcher, BatchedCommand, CommandBatch, CpuBatchDispatcher,
135        WgpuEmulationConfig, WgpuPersistentHandle, WgpuPersistentHandleBuilder,
136    };
137
138    #[cfg(feature = "arrow")]
139    pub use crate::arrow::*;
140
141    #[cfg(feature = "polars")]
142    pub use crate::polars::*;
143
144    #[cfg(feature = "grpc")]
145    pub use crate::grpc::*;
146
147    #[cfg(feature = "candle")]
148    pub use crate::candle::*;
149
150    #[cfg(feature = "config")]
151    pub use crate::config::*;
152
153    #[cfg(feature = "prometheus")]
154    pub use crate::metrics::*;
155
156    #[cfg(all(feature = "enterprise", feature = "axum"))]
157    pub use crate::enterprise::{
158        enterprise_routes, health_handler as enterprise_health_handler, liveness_handler,
159        metrics_handler as enterprise_metrics_handler, readiness_handler, stats_handler,
160    };
161    #[cfg(all(feature = "enterprise", feature = "tower"))]
162    pub use crate::enterprise::{
163        CircuitBreakerFuture, CircuitBreakerLayer, CircuitBreakerService, DegradationFuture,
164        DegradationLayer, DegradationService,
165    };
166    #[cfg(feature = "enterprise")]
167    pub use crate::enterprise::{
168        EnterpriseHealthResponse, EnterpriseState, EnterpriseStatsResponse, LivenessResponse,
169        ReadinessResponse,
170    };
171
172    #[cfg(feature = "graphql")]
173    pub use crate::graphql::{
174        create_schema, CommandAck, DynPersistentHandle, GraphQLState, InjectInput,
175        KernelConfigResponse, KernelEvent, KernelEventType, KernelMutation, KernelQuery,
176        KernelSchema, KernelStatsResponse, KernelStatus, KernelSubscription, ProgressUpdate,
177        RunStepsInput,
178    };
179    #[cfg(all(feature = "graphql", feature = "axum"))]
180    pub use crate::graphql::{graphql_handler, graphql_playground, graphql_router};
181}