oa_gateway_stomp::adapter

Struct StompAdapter

Source
pub struct StompAdapter {
    id: AdapterId,
    config: StompConfig,
}
Expand description

STOMP client that bridges configured topics both ways.

Inbound MESSAGE frames are stamped with oag.origin_adapter so outbound SEND can refuse the echo when StompConfig::suppress_echo is on. Engine::drop_adapter runs at session start and end so a reconnect does not keep stale subscriptions.

Fields§

§id: AdapterId§config: StompConfig

Implementations§

Source§

impl StompAdapter

Source

pub fn new(id: impl Into<AdapterId>, config: StompConfig) -> Self

Builds an adapter that is not yet connected.

Source

pub fn id(&self) -> &AdapterId

Source

pub fn config(&self) -> &StompConfig

Source

pub async fn serve( self: Arc<Self>, engine: Arc<Engine>, shutdown: CancellationToken, ) -> Result<(), AdapterError>

Connects, subscribes, and bridges until shutdown or a fatal session error with reconnect off.

§Errors

Returns AdapterError::Failed if connect, SUBSCRIBE, or the session fails and StompConfig::reconnect is false; if a session panics and StompConfig::on_panic is abort; or if shutdown has already fired.

Source

pub async fn serve_ready( self: Arc<Self>, engine: Arc<Engine>, shutdown: CancellationToken, ready: Sender<()>, ) -> Result<(), AdapterError>

Same as Self::serve, then signals ready after the first CONNECTED and engine subscriptions.

Used by tests that must not publish before the bridge is up. Later reconnects do not signal again.

§Errors

Same as Self::serve.

Source

async fn serve_inner( self: Arc<Self>, engine: Arc<Engine>, shutdown: CancellationToken, ready: Option<Sender<()>>, ) -> Result<(), AdapterError>

Retry loop. Delay comes from StompConfig::reconnect_delay. ready is taken on the first session only.

Source

async fn session( &self, engine: &Arc<Engine>, shutdown: &CancellationToken, ready: Option<Sender<()>>, ) -> Result<(), AdapterError>

One CONNECT through DISCONNECT.

Drops this adapter’s engine subscriptions before SUBSCRIBE so a previous session cannot leave keys behind. Engine subscribe uses RouteKey::topic (wildcard) for each configured topic.

§Errors

Returns AdapterError::Failed if the broker cannot be reached, SUBSCRIBE fails, or Self::drive_session fails.

Source

async fn drive_session( &self, reader: &mut FrameReader, writer: &mut FrameWriter, engine: &Arc<Engine>, shutdown: &CancellationToken, map: &DestinationMap, eng_rx: &mut Receiver<Delivery>, ) -> Result<(), AdapterError>

Reads broker frames and engine deliveries until shutdown or a broken connection.

A clean broker close is an error so reconnect can fire. A dropped engine channel is Ok.

§Errors

Returns AdapterError::Failed if the broker closes, a read fails, or an outbound SEND cannot be written.

Source

async fn handle_frame( &self, engine: &Arc<Engine>, map: &DestinationMap, frame: Frame, ) -> Result<(), String>

Handles one inbound frame. MESSAGE is published; ERROR fails the session; RECEIPT is ignored.

§Errors

Returns a message for a broker ERROR or a MESSAGE that cannot be mapped onto an envelope.

Trait Implementations§

Source§

impl Adapter for StompAdapter

Source§

fn run<'async_trait>( self: Arc<Self>, engine: Arc<Engine>, shutdown: CancellationToken, ) -> Pin<Box<dyn Future<Output = Result<(), AdapterError>> + Send + 'async_trait>>
where Self: 'async_trait,

Source§

fn id(&self) -> &AdapterId

Stable id for this adapter instance. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more