Skip to main content

hyperi_rustlib/transport/
mod.rs

1// Project:   hyperi-rustlib
2// File:      src/transport/mod.rs
3// Purpose:   Transport abstraction layer for message delivery
4// Language:  Rust
5//
6// License:   BUSL-1.1
7// Copyright: (c) 2026 HYPERI PTY LIMITED
8
9//! # Transport Abstraction Layer
10//!
11//! Pluggable message transport with split sender/receiver traits for
12//! type-safe factory construction and runtime transport selection.
13//!
14//! ## Architecture
15//!
16//! ```text
17//! TransportSender (object-safe)     TransportReceiver<Token> (generic)
18//!   send(key, payload)                recv(max) -> Vec<Message<Token>>
19//!   close()                           commit(tokens)
20//!   is_healthy()                      close()
21//!   name()                            is_healthy(), name()
22//!         |                                    |
23//!         +-------- Transport (blanket) -------+
24//! ```
25//!
26//! - **Output stages** (DLQ, forwarding, archiving): use `Box<dyn TransportSender>`
27//! - **Input stages** (receiver, fetcher): use concrete `impl TransportReceiver`
28//! - **Factory**: `sender_from_config()` returns `Box<dyn TransportSender>`
29//!
30//! ## Transport Selection
31//!
32//! | Transport | Send | Recv | Use Case |
33//! |-----------|------|------|----------|
34//! | **Kafka** | Yes | Yes | Production default, PB/day, persistence |
35//! | **gRPC** | Yes | Yes | Low-latency direct, DFE mesh |
36//! | **Memory** | Yes | Yes | Unit tests, same-process |
37//! | **File** | Yes | Yes | Debugging, audit trails, replay |
38//! | **Pipe** | Yes | Yes | Unix pipelines, sidecar pattern |
39//! | **HTTP** | Yes | Yes | Webhook delivery, REST ingest |
40//! | **Redis** | Yes | Yes | Edge deployments, lightweight pub/sub |
41//!
42//! ## Example
43//!
44//! ```rust,ignore
45//! use hyperi_rustlib::transport::{TransportSender, TransportConfig};
46//!
47//! // Factory creates the right backend from config
48//! let sender: Box<dyn TransportSender> = transport::sender_from_config("transport.output").await?;
49//! sender.send("events.land", payload).await;
50//! ```
51
52pub mod codec;
53mod detect;
54mod error;
55pub mod factory;
56pub mod filter;
57pub mod propagation;
58mod traits;
59mod types;
60mod work_batch;
61
62pub use types::PayloadFormat;
63
64// Re-export stateful format detection
65pub use detect::{DetectedFormat, FormatDetector, FormatMode, detect_format};
66
67#[cfg(feature = "transport-kafka")]
68pub mod kafka;
69
70#[cfg(feature = "transport-grpc")]
71pub mod grpc;
72
73#[cfg(feature = "transport-grpc-vector-compat")]
74pub mod vector_compat;
75
76#[cfg(feature = "transport-memory")]
77pub mod memory;
78
79#[cfg(feature = "transport-pipe")]
80pub mod pipe;
81
82#[cfg(feature = "transport-file")]
83pub mod file;
84
85#[cfg(feature = "transport-http")]
86pub mod http;
87
88#[cfg(feature = "transport-redis")]
89pub mod redis_transport;
90
91pub mod routed;
92
93// Re-exports -- traits and factory
94pub use codec::{CodecError, FieldRef, ParsedPayload, parse};
95pub use error::{TransportError, TransportResult};
96pub use factory::{AnyReceiver, AnySender, AnyToken};
97pub use routed::RoutedSender;
98pub use traits::{
99    CommitToken, FromCascade, RecvBatch, RecvLimits, Transport, TransportBase, TransportReceiver,
100    TransportSender,
101};
102pub use types::{Message, SendResult, TransportConfig, TransportType};
103pub use work_batch::{FramingError, Record, RecordMeta, WorkBatch};
104
105#[cfg(feature = "transport-kafka")]
106pub use kafka::{KafkaConfig, KafkaToken, KafkaTransport};
107
108#[cfg(feature = "transport-grpc")]
109pub use grpc::{GrpcConfig, GrpcToken, GrpcTransport};
110
111#[cfg(feature = "transport-grpc-vector-compat")]
112pub use vector_compat::{VectorCompatClient, VectorCompatService};
113
114#[cfg(feature = "transport-memory")]
115pub use memory::{MemoryConfig, MemoryToken, MemoryTransport};
116
117#[cfg(feature = "transport-pipe")]
118pub use pipe::{PipeToken, PipeTransport, PipeTransportConfig};
119
120#[cfg(feature = "transport-file")]
121pub use file::{FileToken, FileTransport, FileTransportConfig};
122
123#[cfg(feature = "transport-http")]
124pub use http::{HttpToken, HttpTransport, HttpTransportConfig};
125
126#[cfg(feature = "transport-redis")]
127pub use redis_transport::{RedisToken, RedisTransport, RedisTransportConfig};