pub struct ConsumerClient {
config: ConsumerClientConfig,
stream: Stream<Info>,
consumer: Consumer<Config>,
consumer_list: Vec<String>,
consumer_list_last_update: Instant,
new_worker_subscription: Subscriber,
consumer_deleted_subscription: Subscriber,
}Expand description
Handle controlling a single consumer.
Fields§
§config: ConsumerClientConfigConfiguration used for setting up this consumer. See ConsumerClientConfig for more info.
stream: Stream<Info>The stream over which the consumer was created.
consumer: Consumer<Config>The actual JetStream consumer.
consumer_list: Vec<String>The list of other consumers we currently know about.
consumer_list_last_update: InstantWhen we last updated the list of consumers on the stream.
new_worker_subscription: SubscriberA subscription to the subject in which new workers are announced.
consumer_deleted_subscription: SubscriberA subscription to the subject in which deleted consumers are announced.
Implementations§
Source§impl ConsumerClient
impl ConsumerClient
Sourcepub async fn new(
config: ConsumerClientConfig,
client: Client,
stream: Stream<Info>,
) -> Result<Self, Error>
pub async fn new( config: ConsumerClientConfig, client: Client, stream: Stream<Info>, ) -> Result<Self, Error>
Creates a new ConsumerClient over a stream.
Sourceasync fn update_consumer_list(&mut self) -> Result<(), Error>
async fn update_consumer_list(&mut self) -> Result<(), Error>
Updates the list of other consumers we know are connected on the stream.
Sourceasync fn update_filter_subjects(&mut self) -> Result<(), Error>
async fn update_filter_subjects(&mut self) -> Result<(), Error>
Updates the list of subjects we are consuming.
Sourceasync fn handle_new_worker_message(
&mut self,
msg: Option<Message>,
) -> Result<(), Error>
async fn handle_new_worker_message( &mut self, msg: Option<Message>, ) -> Result<(), Error>
Handles a notification for a new consumer arriving, possibly triggering a re-distribution of the stream’s partition.
Sourceasync fn handle_worker_deleted_message(
&mut self,
msg: Option<Message>,
) -> Result<(), Error>
async fn handle_worker_deleted_message( &mut self, msg: Option<Message>, ) -> Result<(), Error>
Handles a notification for a consumer on the stream going offline, possibly triggering a re-distribution of the stream partition.
Sourcepub async fn get_message(&mut self) -> Result<Option<Message>, Error>
pub async fn get_message(&mut self) -> Result<Option<Message>, Error>
Makes sure that the distribution of rooms between ConsumerClients is correct, and then tries to fetch the next message
§Returns
Returns the Message. If it returns None, this means
it has reached fetch_timeout without a message being received
Trait Implementations§
Source§impl Debug for ConsumerClient
impl Debug for ConsumerClient
Source§impl Drop for ConsumerClient
Tries deleting the ConsumerClient from the NATS JetStream.
impl Drop for ConsumerClient
Tries deleting the ConsumerClient from the NATS JetStream.
Auto Trait Implementations§
impl !RefUnwindSafe for ConsumerClient
impl !UnwindSafe for ConsumerClient
impl Freeze for ConsumerClient
impl Send for ConsumerClient
impl Sync for ConsumerClient
impl Unpin for ConsumerClient
impl UnsafeUnpin for ConsumerClient
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> JsonCastable<CanonicalJsonValue> for T
impl<T> JsonCastable<Value> for T
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more