pub struct ClientSessionBuilder { /* private fields */ }Expand description
Builder for constructing ClientSession instances
Provides a fluent API for creating client sessions with different routing modes.
§Examples
use std::net::SocketAddr;
use std::sync::Arc;
use nntp_proxy::session::ClientSession;
use nntp_proxy::pool::BufferPool;
use nntp_proxy::router::BackendSelector;
use nntp_proxy::config::RoutingMode;
use nntp_proxy::types::BufferSize;
use nntp_proxy::auth::AuthHandler;
let addr: SocketAddr = "127.0.0.1:8080".parse().unwrap();
let buffer_pool = BufferPool::new(BufferSize::DEFAULT, 10);
let auth_handler = Arc::new(AuthHandler::new(None, None));
// Standard 1:1 routing mode
let session = ClientSession::builder(addr, buffer_pool.clone(), auth_handler.clone())
.build();
// Per-command routing mode
let router = Arc::new(BackendSelector::new());
let session = ClientSession::builder(addr, buffer_pool.clone(), auth_handler)
.with_router(router)
.with_routing_mode(RoutingMode::PerCommand)
.build();Implementations§
Source§impl ClientSessionBuilder
impl ClientSessionBuilder
Sourcepub fn with_router(self, router: Arc<BackendSelector>) -> Self
pub fn with_router(self, router: Arc<BackendSelector>) -> Self
Configure the session to use per-command routing with a backend router
When a router is provided, the session will route each command independently to potentially different backend servers.
Sourcepub fn with_routing_mode(self, mode: RoutingMode) -> Self
pub fn with_routing_mode(self, mode: RoutingMode) -> Self
Set the routing mode for this session
§Arguments
mode- The routing mode (Standard, PerCommand, or Hybrid)
Note: If you use with_router(), you typically want PerCommand or Hybrid mode.
Sourcepub fn with_auth_handler(self, auth_handler: Arc<AuthHandler>) -> Self
pub fn with_auth_handler(self, auth_handler: Arc<AuthHandler>) -> Self
Set the authentication handler
Sourcepub fn build(self) -> ClientSession
pub fn build(self) -> ClientSession
Build the client session
Creates a new ClientSession with a unique client ID and the configured
routing mode.
Auto Trait Implementations§
impl Freeze for ClientSessionBuilder
impl !RefUnwindSafe for ClientSessionBuilder
impl Send for ClientSessionBuilder
impl Sync for ClientSessionBuilder
impl Unpin for ClientSessionBuilder
impl !UnwindSafe for ClientSessionBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more