1mod backpressure;
13mod core_handle;
14mod partitioned_router;
15mod router;
16mod runtime;
17mod spsc;
18#[cfg(test)]
19mod zero_alloc_tests;
20
21pub use backpressure::{
22 BackpressureConfig, BackpressureConfigBuilder, CreditAcquireResult, CreditGate, CreditMetrics,
23 CreditMetricsSnapshot, OverflowStrategy,
24};
25pub use core_handle::{CoreConfig, CoreHandle, CoreMessage, TaggedOutput};
26pub use partitioned_router::PartitionedRouter;
27pub use router::{KeySpec, RouterError};
28pub use runtime::{OutputBuffer, TpcConfig, TpcConfigBuilder};
29pub use spsc::{CachePadded, SpscQueue};
30
31#[derive(Debug, thiserror::Error)]
33pub enum TpcError {
34 #[error("Failed to spawn core {core_id}: {message}")]
36 SpawnFailed {
37 core_id: usize,
39 message: String,
41 },
42
43 #[error("Failed to set CPU affinity for core {core_id}: {message}")]
45 AffinityFailed {
46 core_id: usize,
48 message: String,
50 },
51
52 #[error("Queue full for core {core_id}")]
54 QueueFull {
55 core_id: usize,
57 },
58
59 #[error("Backpressure active for core {core_id}")]
61 Backpressure {
62 core_id: usize,
64 },
65
66 #[error("Runtime is not running")]
68 NotRunning,
69
70 #[error("Runtime is already running")]
72 AlreadyRunning,
73
74 #[error("Invalid configuration: {0}")]
76 InvalidConfig(String),
77
78 #[error("Reactor error on core {core_id}: {source}")]
80 ReactorError {
81 core_id: usize,
83 #[source]
85 source: crate::reactor::ReactorError,
86 },
87
88 #[error("Operator panic on core {core_id}: {message}")]
90 OperatorPanic {
91 core_id: usize,
93 message: String,
95 },
96
97 #[error("Key extraction failed: {0}")]
99 KeyExtractionFailed(String),
100
101 #[error("Router error: {0}")]
103 RouterError(#[from] RouterError),
104}
105
106#[cfg(test)]
107mod tests {
108 use super::*;
109
110 #[test]
111 fn test_error_display() {
112 let err = TpcError::QueueFull { core_id: 3 };
113 assert_eq!(err.to_string(), "Queue full for core 3");
114 }
115}