Skip to main content

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::unwrap_used)]
31#![warn(clippy::all)]
32
33pub mod error;
34
35#[cfg(feature = "persistent")]
36pub mod persistent;
37
38#[cfg(feature = "persistent-cuda")]
39pub mod cuda_bridge;
40
41#[cfg(feature = "actix")]
42pub mod actix;
43
44#[cfg(feature = "tower")]
45pub mod tower;
46
47#[cfg(feature = "axum")]
48pub mod axum;
49
50#[cfg(feature = "arrow")]
51pub mod arrow;
52
53#[cfg(feature = "polars")]
54pub mod polars;
55
56#[cfg(feature = "grpc")]
57pub mod grpc;
58
59#[cfg(feature = "candle")]
60pub mod candle;
61
62#[cfg(feature = "config")]
63pub mod config;
64
65#[cfg(feature = "tracing-integration")]
66pub mod tracing_ext;
67
68#[cfg(feature = "prometheus")]
69pub mod metrics;
70
71#[cfg(feature = "graphql")]
72pub mod graphql;
73
74/// LLM provider bridge (OpenAI, Anthropic, local models).
75pub mod llm;
76
77/// Streaming integrations (Kafka, Redis Streams, NATS).
78pub mod streaming;
79
80/// Machine learning framework bridge.
81#[cfg(feature = "candle")]
82pub mod ml_bridge;
83
84#[cfg(feature = "enterprise")]
85pub mod enterprise;
86
87#[cfg(feature = "ml-bridge")]
88pub mod ml_bridge;
89
90/// Prelude for convenient imports.
91///
92/// Note: Each integration module defines its own `RuntimeHandle` trait with
93/// different bounds. To avoid conflicts, import the specific `RuntimeHandle`
94/// from the module you're using (e.g., `use ringkernel_ecosystem::axum::RuntimeHandle`).
95pub mod prelude {
96    pub use crate::error::*;
97
98    #[cfg(feature = "persistent")]
99    pub use crate::persistent::*;
100
101    // Re-export commonly used types, excluding RuntimeHandle to avoid conflicts
102    #[cfg(feature = "actix")]
103    pub use crate::actix::{
104        BridgeHealth, GpuActorBridge, GpuActorConfig, GpuActorExt, GpuRequest, GpuResponse,
105        HealthCheck, TypedGpuRequest,
106    };
107    #[cfg(all(feature = "actix", feature = "persistent"))]
108    pub use crate::actix::{
109        GetStatsCmd, GpuPersistentActor, GpuPersistentActorExt, InjectCmd, PauseCmd,
110        PersistentActorConfig, PersistentResponseMsg, ResumeCmd, RunStepsCmd, ShutdownCmd,
111        Subscribe, Unsubscribe,
112    };
113
114    #[cfg(all(feature = "tower", feature = "persistent"))]
115    pub use crate::tower::{
116        PersistentKernelLayer, PersistentKernelService, PersistentServiceBuilder,
117        PersistentServiceConfig, PersistentServiceRequest, PersistentServiceResponse,
118    };
119    #[cfg(feature = "tower")]
120    pub use crate::tower::{
121        RingKernelLayer, RingKernelService, ServiceBuilder, ServiceConfig, ServiceRequest,
122        ServiceResponse,
123    };
124
125    #[cfg(feature = "axum")]
126    pub use crate::axum::{
127        gpu_handler, health_handler, ApiRequest, ApiResponse, AppState, AxumConfig, HealthResponse,
128        KernelHealth, RequestStats, RouterBuilder, StatsSnapshot,
129    };
130    #[cfg(all(feature = "axum", feature = "persistent"))]
131    pub use crate::axum::{
132        impulse_handler, pause_handler, persistent_health_handler, persistent_stats_handler,
133        resume_handler, step_handler, CommandResponse, ImpulseRequest, PersistentAxumConfig,
134        PersistentGpuState, PersistentHealthResponse, PersistentStatsResponse, StepRequest,
135    };
136
137    #[cfg(feature = "persistent-cuda")]
138    pub use crate::cuda_bridge::{CudaPersistentHandle, CudaPersistentHandleBuilder};
139
140    #[cfg(feature = "arrow")]
141    pub use crate::arrow::*;
142
143    #[cfg(feature = "polars")]
144    pub use crate::polars::*;
145
146    #[cfg(feature = "grpc")]
147    pub use crate::grpc::*;
148
149    #[cfg(feature = "candle")]
150    pub use crate::candle::*;
151
152    #[cfg(feature = "config")]
153    pub use crate::config::*;
154
155    #[cfg(feature = "prometheus")]
156    pub use crate::metrics::*;
157
158    #[cfg(all(feature = "enterprise", feature = "axum"))]
159    pub use crate::enterprise::{
160        enterprise_routes, health_handler as enterprise_health_handler, liveness_handler,
161        metrics_handler as enterprise_metrics_handler, readiness_handler, stats_handler,
162    };
163    #[cfg(all(feature = "enterprise", feature = "tower"))]
164    pub use crate::enterprise::{
165        CircuitBreakerFuture, CircuitBreakerLayer, CircuitBreakerService, DegradationFuture,
166        DegradationLayer, DegradationService,
167    };
168    #[cfg(feature = "enterprise")]
169    pub use crate::enterprise::{
170        EnterpriseHealthResponse, EnterpriseState, EnterpriseStatsResponse, LivenessResponse,
171        ReadinessResponse,
172    };
173
174    #[cfg(feature = "graphql")]
175    pub use crate::graphql::{
176        create_schema, CommandAck, DynPersistentHandle, GraphQLState, InjectInput,
177        KernelConfigResponse, KernelEvent, KernelEventType, KernelMutation, KernelQuery,
178        KernelSchema, KernelStatsResponse, KernelStatus, KernelSubscription, ProgressUpdate,
179        RunStepsInput,
180    };
181    #[cfg(all(feature = "graphql", feature = "axum"))]
182    pub use crate::graphql::{graphql_handler, graphql_playground, graphql_router};
183}