pub struct CoreSubject { /* private fields */ }Expand description
One subject subscribed to over Core NATS.
Core NATS delivers to whoever is subscribed at that moment and stores nothing, so the only
setting it has is the queue group that load-balances a subject across several subscribers.
Reading a stream instead is JetStreamSubject; reading many subjects at once is
CoreWildcard.
The subject is one destination, so a delayed redelivery needs nothing from the mount site: the framework publishes its copy back to this very subject.
§Examples
use ruststream_nats::prelude::*;
use serde::Deserialize;
#[derive(Deserialize)]
struct Order {
id: u64,
}
// Every replica joins `workers`, so each order reaches one of them.
#[subscriber(CoreSubject::new("orders.created").queue_group("workers"))]
async fn fulfil(order: &Order) -> HandlerOutcome {
println!("fulfilling order {}", order.id);
HandlerOutcome::ack()
}
#[ruststream::app]
fn app() -> impl App {
RustStream::new(AppInfo::new("fulfillment", "0.1.0")).with_broker(
NatsBroker::new("nats://localhost:4222"),
|b| {
b.include(fulfil);
},
)
}A JetStream setting is not a method here, so asking for one does not compile:
use ruststream_nats::CoreSubject;
// `durable` names a JetStream consumer, and Core NATS has none.
let bad = CoreSubject::new("orders.created").durable("worker-1");Implementations§
Trait Implementations§
Source§impl Clone for CoreSubject
impl Clone for CoreSubject
Source§impl Debug for CoreSubject
impl Debug for CoreSubject
impl Eq for CoreSubject
Source§impl IntoSource for CoreSubject
A descriptor is already a source, so the macro-free constructor takes it as it stands:
subscriber(JetStreamSubject::new("orders.*", "ORDERS"), body) names the same subscription
the #[subscriber(..)] attribute does.
impl IntoSource for CoreSubject
A descriptor is already a source, so the macro-free constructor takes it as it stands:
subscriber(JetStreamSubject::new("orders.*", "ORDERS"), body) names the same subscription
the #[subscriber(..)] attribute does.
§Examples
use ruststream::schemars::JsonSchema;
use ruststream_nats::prelude::*;
use serde::Deserialize;
#[derive(Deserialize, JsonSchema)]
struct Order {
id: u64,
}
struct Audit;
impl Handle<Order> for Audit {
async fn handle(
&self,
order: &Order,
_outs: &(),
_ctx: &mut Context<'_>,
) -> Result<(), HandlerOutcome> {
println!("auditing order {}", order.id);
Ok(())
}
}
#[ruststream::app]
fn app() -> impl App {
RustStream::new(AppInfo::new("audit", "0.1.0")).with_broker(
NatsBroker::new("nats://localhost:4222"),
|b| {
let audited = CoreSubject::new("orders.created").queue_group("auditors");
b.include(subscriber(audited, Audit).build());
},
)
}Source§type Source = CoreSubject
type Source = CoreSubject
Source§fn into_source(self) -> Self
fn into_source(self) -> Self
Source§impl NatsSubscription for CoreSubject
impl NatsSubscription for CoreSubject
Source§fn ensure_subject(&self) -> Result<(), NatsError>
fn ensure_subject(&self) -> Result<(), NatsError>
A wildcard belongs to CoreWildcard, so it is refused here rather than opened as a
subscription this type promises to address.
The subject is a string the caller supplies, often from configuration, so the two forms cannot be told apart while the crate compiles. The subscription refuses to open instead, which is a service that does not start rather than one that starts and loses a delayed message.
Source§impl PartialEq for CoreSubject
impl PartialEq for CoreSubject
Source§impl RedeliveryAddressed<ConnectedNatsBroker> for CoreSubject
The subject itself, so the answer needs no connection and the future is ready.
impl RedeliveryAddressed<ConnectedNatsBroker> for CoreSubject
The subject itself, so the answer needs no connection and the future is ready.
Source§fn redelivery_address(
&self,
_connected: &ConnectedNatsBroker,
) -> impl Future<Output = Result<RedeliveryAddress, NatsError>> + Send
fn redelivery_address( &self, _connected: &ConnectedNatsBroker, ) -> impl Future<Output = Result<RedeliveryAddress, NatsError>> + Send
impl StructuralPartialEq for CoreSubject
Source§impl SubscriptionSource<ConnectedNatsBroker> for CoreSubject
impl SubscriptionSource<ConnectedNatsBroker> for CoreSubject
Source§type Subscriber = NatsSubscriber
type Subscriber = NatsSubscriber
Source§type Copies = AddressedCopies
type Copies = AddressedCopies
AddressedCopies, NamedCopies or BrokerMoves. Read moreSource§async fn subscribe(
self,
connected: &ConnectedNatsBroker,
) -> Result<Self::Subscriber, NatsError>
async fn subscribe( self, connected: &ConnectedNatsBroker, ) -> Result<Self::Subscriber, NatsError>
Source§fn operation_bindings(&self) -> Bindings
fn operation_bindings(&self) -> Bindings
receive operation in the document. Read moreSource§fn declare_retry(self, declaration: &RetryDeclaration) -> Selfwhere
Self: Sized,
fn declare_retry(self, declaration: &RetryDeclaration) -> Selfwhere
Self: Sized,
Source§fn declare_retry_on(
&self,
connected: &C,
declaration: &RetryDeclaration,
) -> Result<(), DeclareRetryError>
fn declare_retry_on( &self, connected: &C, declaration: &RetryDeclaration, ) -> Result<(), DeclareRetryError>
Source§fn channel_bindings(&self) -> Bindings
fn channel_bindings(&self) -> Bindings
AsyncAPI document. Read moreSource§fn message_bindings(&self) -> Bindings
fn message_bindings(&self) -> Bindings
Auto Trait Implementations§
impl Freeze for CoreSubject
impl RefUnwindSafe for CoreSubject
impl Send for CoreSubject
impl Sync for CoreSubject
impl Unpin for CoreSubject
impl UnsafeUnpin for CoreSubject
impl UnwindSafe for CoreSubject
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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