pub struct UdpStreamService { /* private fields */ }Expand description
UDP stream proxy service
Listens on a port and proxies UDP datagrams to registered backends. Maintains session state to route responses back to the correct client.
Implementations§
Source§impl UdpStreamService
impl UdpStreamService
Sourcepub fn new(
registry: Arc<StreamRegistry>,
listen_port: u16,
session_timeout: Option<Duration>,
) -> Self
pub fn new( registry: Arc<StreamRegistry>, listen_port: u16, session_timeout: Option<Duration>, ) -> Self
Create a new UDP stream service
Sourcepub fn session_timeout(&self) -> Duration
pub fn session_timeout(&self) -> Duration
Get the session timeout
Sourcepub fn registry(&self) -> &Arc<StreamRegistry>
pub fn registry(&self) -> &Arc<StreamRegistry>
Get a reference to the registry
Sourcepub async fn run(self: Arc<Self>) -> Result<(), Box<dyn Error + Send + Sync>>
pub async fn run(self: Arc<Self>) -> Result<(), Box<dyn Error + Send + Sync>>
Run the UDP proxy service by binding its own socket.
This method runs indefinitely, proxying UDP datagrams between clients and backends. Each client address gets its own session.
§Errors
Returns an error if binding to the listen port fails or if the main receive loop encounters a fatal IO error.
Sourcepub async fn serve(
self: Arc<Self>,
socket: UdpSocket,
) -> Result<(), Box<dyn Error + Send + Sync>>
pub async fn serve( self: Arc<Self>, socket: UdpSocket, ) -> Result<(), Box<dyn Error + Send + Sync>>
Run the UDP proxy service on an externally-provided socket.
This is the non-self-binding entry point, used by ProxyManager to serve
UDP endpoints when the caller has already bound the socket.
Runs indefinitely, proxying UDP datagrams between clients and backends. Each client address gets its own session with a dedicated backend socket.
§Errors
Returns an error if the main receive loop encounters a fatal IO error or if creating a backend session socket fails.