Skip to main content

ConnectedMemoryBroker

Struct ConnectedMemoryBroker 

Source
pub struct ConnectedMemoryBroker<Log = Discarding> { /* private fields */ }
Expand description

The connected form of MemoryBroker: the typed witness that Broker::connect ran.

Cheap to clone: the in-memory bus is shared state by nature, so the connected form is a shareable handle on it, exactly like the unconnected broker. Subscriptions (the Subscribe capability, MemorySource) resolve against this form, and carry over the broker’s log mode: only a Retaining one opens repositionable subscriptions.

Implementations§

Source§

impl<Log: LogMode> ConnectedMemoryBroker<Log>

Source

pub fn publisher(&self) -> MemoryPublisher

Returns a publisher bound to this broker.

Source

pub fn requester(&self) -> MemoryRequester

Returns a request / reply-capable publisher bound to this broker.

See MemoryBroker::requester for why its operations report RequestError rather than MemoryError.

Trait Implementations§

Source§

impl<Log> Clone for ConnectedMemoryBroker<Log>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Log: LogMode> ConnectedBroker for ConnectedMemoryBroker<Log>

Source§

fn shutdown(self) -> impl Future<Output = Result<Self::Closed, Self::Error>>

Enters the terminal shut-down state: the bus itself flips to its ShutDown variant, so every aliased handle that would touch it (a publisher’s publish or transaction commit, a request) errors with MemoryError::ShutDown. Consuming self makes any further use of this handle a compile error; the returned witness reports how many subscriber registrations the teardown dropped.

Source§

type Error = MemoryError

The error type returned by connected-broker operations.
Source§

type Closed = ClosedMemoryBroker

The terminal witness returned by shutdown. Read more
Source§

impl<Log> Debug for ConnectedMemoryBroker<Log>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Log: LogMode> DefaultPublish for ConnectedMemoryBroker<Log>

Source§

type Policy = MemoryPublish

The broker’s plain publish policy, constructible with its defaults.
Source§

impl<Log: LogMode> PublishPolicy<ConnectedMemoryBroker<Log>> for MemoryPublish

Source§

type Live = MemoryPublisher

The live form this policy pairs into: a Publisher for a leaf policy, or the live wiring form for a combinator stack (a typed publisher over a policy pairs into the same typed publisher over the live leaf).
Source§

fn pair( self, connected: &ConnectedMemoryBroker<Log>, ) -> impl Future<Output = Result<Self::Live, PairError>>

Pairs the policy with a connected broker, producing the live publisher. Read more
Source§

fn channel_bindings(&self, channel: &str) -> Bindings

What a publish through this policy adds to its channel in the generated AsyncAPI document. Read more
Source§

fn operation_bindings(&self, channel: &str) -> Bindings

What a publish through this policy adds to its send operation in the document. Read more
Source§

fn message_bindings(&self, channel: &str) -> Bindings

What a publish through this policy adds to the messages that leave through it. Read more
Source§

fn reply_address_location(&self) -> Option<&'static str>

Where a client finds the address of a reply this policy publishes, as a runtime expression. Read more
Source§

impl<Log: LogMode> PublishPolicy<ConnectedMemoryBroker<Log>> for MemoryRequest

Source§

type Live = MemoryRequester

The live form this policy pairs into: a Publisher for a leaf policy, or the live wiring form for a combinator stack (a typed publisher over a policy pairs into the same typed publisher over the live leaf).
Source§

fn pair( self, connected: &ConnectedMemoryBroker<Log>, ) -> impl Future<Output = Result<Self::Live, PairError>>

Pairs the policy with a connected broker, producing the live publisher. Read more
Source§

fn channel_bindings(&self, channel: &str) -> Bindings

What a publish through this policy adds to its channel in the generated AsyncAPI document. Read more
Source§

fn operation_bindings(&self, channel: &str) -> Bindings

What a publish through this policy adds to its send operation in the document. Read more
Source§

fn message_bindings(&self, channel: &str) -> Bindings

What a publish through this policy adds to the messages that leave through it. Read more
Source§

fn reply_address_location(&self) -> Option<&'static str>

Where a client finds the address of a reply this policy publishes, as a runtime expression. Read more
Source§

impl<Log: LogMode> RedeliveryAddressed<ConnectedMemoryBroker<Log>> for MemoryPattern

Source§

fn redelivery_address( &self, _connected: &ConnectedMemoryBroker<Log>, ) -> impl Future<Output = Result<RedeliveryAddress, MemoryError>> + Send

The pattern text. A publish to it matches the pattern token for token (* matches the token *, > the token >), so under Routing::EveryMatch it reaches this subscription.

Source§

impl<Log: LogMode> RedeliveryAddressed<ConnectedMemoryBroker<Log>> for MemorySource

Source§

fn redelivery_address( &self, _connected: &ConnectedMemoryBroker<Log>, ) -> impl Future<Output = Result<RedeliveryAddress, MemoryError>> + Send

Where a publish reaches this subscription again. Read more
Source§

impl<Log: LogMode> Subscribe for ConnectedMemoryBroker<Log>

Source§

fn subscribe( &self, name: &str, ) -> impl Future<Output = Result<Self::Subscriber, Self::Error>>

A name with a wildcard token is refused with MemoryError::WildcardName: this form reads one name, and MemoryPattern is the one that reads a pattern.

Source§

type Subscriber = MemorySubscriber<Log>

The subscriber type opened by a by-name subscription.
Source§

type Copies = AddressedCopies

Who publishes the copies a retry of a by-name subscription is made of, and who names where they go. This is what the Name source reports, so it decides how #[subscriber("orders")] retries on this broker. Read more
Source§

fn declare_retry( &self, name: &str, declaration: &RetryDeclaration, ) -> Result<(), DeclareRetryError>

Takes what a registration mounted by a bare name declared about its retries, before the subscription opens. Read more
Source§

impl<Log: LogMode> SubscriptionSource<ConnectedMemoryBroker<Log>> for MemoryPattern

Source§

type Subscriber = MemorySubscriber

The subscriber type this source opens.
Source§

type Copies = AddressedCopies

Who publishes the copies this subscription’s retries are made of, and who names where they go: AddressedCopies, NamedCopies or BrokerMoves. Read more
Source§

fn name(&self) -> &str

The name (subject / channel) this subscription binds to. Read more
Source§

fn subscribe( self, connected: &ConnectedMemoryBroker<Log>, ) -> impl Future<Output = Result<Self::Subscriber, MemoryError>> + Send

Opens the subscription against the connected broker. Called once at startup. Read more
Source§

fn declare_retry(self, declaration: &RetryDeclaration) -> Self
where Self: Sized,

Takes the registration’s retry declaration into the descriptor, before the subscription opens. Read more
Source§

fn declare_retry_on( &self, connected: &C, declaration: &RetryDeclaration, ) -> Result<(), DeclareRetryError>

Carries the registration’s declaration to the broker, at the same point and before the subscription opens. Read more
Source§

fn channel_bindings(&self) -> Bindings

What this subscription adds to its channel in the generated AsyncAPI document. Read more
Source§

fn operation_bindings(&self) -> Bindings

What this subscription adds to its receive operation in the document. Read more
Source§

fn message_bindings(&self) -> Bindings

What this subscription adds to the messages that arrive on it. Read more
Source§

impl<Log: LogMode> SubscriptionSource<ConnectedMemoryBroker<Log>> for MemorySource

Source§

type Subscriber = MemorySubscriber<Log>

The subscriber type this source opens.
Source§

type Copies = AddressedCopies

Who publishes the copies this subscription’s retries are made of, and who names where they go: AddressedCopies, NamedCopies or BrokerMoves. Read more
Source§

fn name(&self) -> &str

The name (subject / channel) this subscription binds to. Read more
Source§

async fn subscribe( self, connected: &ConnectedMemoryBroker<Log>, ) -> Result<Self::Subscriber, MemoryError>

Opens the subscription against the connected broker. Called once at startup. Read more
Source§

fn declare_retry(self, declaration: &RetryDeclaration) -> Self
where Self: Sized,

Takes the registration’s retry declaration into the descriptor, before the subscription opens. Read more
Source§

fn declare_retry_on( &self, connected: &C, declaration: &RetryDeclaration, ) -> Result<(), DeclareRetryError>

Carries the registration’s declaration to the broker, at the same point and before the subscription opens. Read more
Source§

fn channel_bindings(&self) -> Bindings

What this subscription adds to its channel in the generated AsyncAPI document. Read more
Source§

fn operation_bindings(&self) -> Bindings

What this subscription adds to its receive operation in the document. Read more
Source§

fn message_bindings(&self) -> Bindings

What this subscription adds to the messages that arrive on it. Read more
Source§

impl<Log: LogMode> TestableBroker for ConnectedMemoryBroker<Log>

Available on crate feature testing only.
Source§

fn published(&self, name: &str) -> Vec<RawMessage>

What the broker holds under name: everything published there on a discarding broker (which records for the length of a harness run), and the retained window on a retaining one, so an assertion never claims more than the broker keeps.

Source§

fn routes(&self, destination: &str, subscriptions: &[&str]) -> Vec<usize>

The broker’s own rule, read from the Routing it was built with: a name with a wildcard token is a MemoryPattern subscription, every other one an exact name.

Source§

fn backlog(&self) -> Backlog

A subscription receives what is published after it opens, on either log mode: a retaining broker keeps its log for a seek to replay, not for a subscription to start from.

Source§

fn install_coordinator(&self, coordinator: Coordinator)

Installs the harness coordinator into this broker’s bus for a test run. Idempotent: a second install on the same broker is ignored.
Source§

fn inject(&self, message: OutgoingMessage<'_>)

Injects a message onto the bus as an external producer would, synchronously (no awaiting). Routes through the broker’s normal fanout, so it is recorded and counted like any publish. Read more

Auto Trait Implementations§

§

impl<Log> Freeze for ConnectedMemoryBroker<Log>
where PhantomData<Log>: Freeze,

§

impl<Log> RefUnwindSafe for ConnectedMemoryBroker<Log>

§

impl<Log> Send for ConnectedMemoryBroker<Log>
where PhantomData<Log>: Send,

§

impl<Log> Sync for ConnectedMemoryBroker<Log>
where PhantomData<Log>: Sync,

§

impl<Log> Unpin for ConnectedMemoryBroker<Log>
where PhantomData<Log>: Unpin,

§

impl<Log> UnsafeUnpin for ConnectedMemoryBroker<Log>

§

impl<Log> UnwindSafe for ConnectedMemoryBroker<Log>
where PhantomData<Log>: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> PublishedThrough<DefaultSlot> for T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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