pub struct ClientHandler { /* private fields */ }Expand description
Client-side request handler bundle.
Built by crate::net::proxy::Proxy and passed into
client_loop.
Implementations§
Source§impl ClientHandler
impl ClientHandler
Sourcepub fn new(
dispatcher: Arc<dyn Dispatcher>,
response_tx: Sender<OutboundEnvelope>,
data_store: DataStore,
) -> Self
pub fn new( dispatcher: Arc<dyn Dispatcher>, response_tx: Sender<OutboundEnvelope>, data_store: DataStore, ) -> Self
Build a client handler.
§Examples
use dynomite::conf::DataStore;
use dynomite::net::{ClientHandler, NoopDispatcher};
use std::sync::Arc;
use tokio::sync::mpsc;
let (tx, _rx) = mpsc::channel(1);
let _h = ClientHandler::new(Arc::new(NoopDispatcher), tx, DataStore::Redis);Sourcepub fn with_read_timeout(self, t: Option<Duration>) -> Self
pub fn with_read_timeout(self, t: Option<Duration>) -> Self
Set the per-read timeout. None disables it.
Sourcepub fn with_gossip(self, gossip: Arc<GossipHandler>) -> Self
pub fn with_gossip(self, gossip: Arc<GossipHandler>) -> Self
Attach a gossip handler. Inbound peer connections served
through this handler dispatch gossip-class dnode frames
into the supplied handler instead of the datastore parser.
Data-plane connections (CLIENT role) leave it None.
Sourcepub fn gossip(&self) -> Option<&Arc<GossipHandler>>
pub fn gossip(&self) -> Option<&Arc<GossipHandler>>
Borrow the attached gossip handler, if any.
Sourcepub fn data_store(&self) -> DataStore
pub fn data_store(&self) -> DataStore
Datastore the handler parses.
Sourcepub fn dispatcher(&self) -> &Arc<dyn Dispatcher> ⓘ
pub fn dispatcher(&self) -> &Arc<dyn Dispatcher> ⓘ
Borrow the dispatcher this handler routes parsed requests into. Exposed so role-specific drivers (CLIENT, DNODE_PEER_CLIENT) can share the same dispatch contract.
§Examples
use dynomite::conf::DataStore;
use dynomite::net::{ClientHandler, NoopDispatcher};
use std::sync::Arc;
use tokio::sync::mpsc;
let (tx, _rx) = mpsc::channel(1);
let h = ClientHandler::new(Arc::new(NoopDispatcher), tx, DataStore::Redis);
let _ = h.dispatcher();Sourcepub fn response_tx(&self) -> &Sender<OutboundEnvelope>
pub fn response_tx(&self) -> &Sender<OutboundEnvelope>
Borrow the per-connection response sender. The dispatcher uses a clone of this channel to push asynchronously-produced responses back to the FSM.
§Examples
use dynomite::conf::DataStore;
use dynomite::net::{ClientHandler, NoopDispatcher};
use std::sync::Arc;
use tokio::sync::mpsc;
let (tx, _rx) = mpsc::channel(1);
let h = ClientHandler::new(Arc::new(NoopDispatcher), tx, DataStore::Redis);
let _clone = h.response_tx().clone();