pub struct BrokerSession { /* private fields */ }Expand description
A negotiated, dialed, and framed broker backend connection.
Produced by BrokerSession::adopt. Wraps the
BackendConnection stream in a
FrameClient so the caller can issue correlated request/response frames
immediately, while still exposing how the connection was reached
(route), the cacheable endpoint, and the
broker’s negotiated metadata.
Implementations§
Source§impl BrokerSession
impl BrokerSession
Sourcepub fn adopt(request: ConnectBackendRequest<'_>) -> Result<Self, AdoptError>
pub fn adopt(request: ConnectBackendRequest<'_>) -> Result<Self, AdoptError>
Negotiate through the broker and return a ready-to-talk session.
Honours the canonical escape hatch first: if
RUNNING_PROCESS_DISABLE=1 is set, this returns
AdoptError::BrokerDisabled so the consumer falls back to its direct
path instead of silently dialing the broker. An invalid disable value
surfaces as AdoptError::DisableEnv.
Sourcepub fn route(&self) -> BackendConnectionRoute
pub fn route(&self) -> BackendConnectionRoute
How the backend connection was reached.
Sourcepub fn endpoint(&self) -> &str
pub fn endpoint(&self) -> &str
Negotiated backend endpoint, suitable as a Hello-skip cache key.
Sourcepub fn negotiated(&self) -> Option<&Negotiated>
pub fn negotiated(&self) -> Option<&Negotiated>
Broker negotiation metadata, present when the broker path was used.
Sourcepub fn request(
&mut self,
payload_protocol: u32,
payload: Vec<u8>,
) -> Result<Frame, FrameClientError>
pub fn request( &mut self, payload_protocol: u32, payload: Vec<u8>, ) -> Result<Frame, FrameClientError>
Send one correlated request and await its response frame.
Sourcepub fn client_mut(&mut self) -> &mut FrameClient
pub fn client_mut(&mut self) -> &mut FrameClient
Borrow the underlying frame client for advanced use.
Sourcepub fn into_client(self) -> FrameClient
pub fn into_client(self) -> FrameClient
Consume the session and return the owned frame client.
Sourcepub fn into_backend_io(self) -> Result<OwnedBackendIo, IntoBackendIoError>
pub fn into_backend_io(self) -> Result<OwnedBackendIo, IntoBackendIoError>
Consume the session and hand back the live negotiated socket as an owned OS handle (#720).
After adoption has driven the broker handshake to completion, a
consumer that wants to stop speaking the FrameV1 request/response wire
and run its own protocol over the same connection calls this to take
ownership of the raw socket. On Unix the result wraps an
OwnedFd; the Windows OwnedHandle path is deferred, so this returns
IntoBackendIoError::WindowsUnsupported there for now.
Fails with IntoBackendIoError::BufferedResidual if the frame
reader has buffered response bytes the bare socket would not carry —
which never happens on a freshly adopted session that has issued no
request.
Auto Trait Implementations§
impl Freeze for BrokerSession
impl RefUnwindSafe for BrokerSession
impl Send for BrokerSession
impl Sync for BrokerSession
impl Unpin for BrokerSession
impl UnsafeUnpin for BrokerSession
impl UnwindSafe for BrokerSession
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more