pub struct ConsumerBuilder { /* private fields */ }Expand description
ConsumerBuilder is a builder for creating a new Consumer instance.
It allows setting various properties for the consumer such as topic, name, subscription, subscription type, and options.
Implementations§
Source§impl ConsumerBuilder
impl ConsumerBuilder
pub fn new(client: &DanubeClient) -> Self
Sourcepub fn with_topic(self, topic: impl Into<String>) -> Self
pub fn with_topic(self, topic: impl Into<String>) -> Self
Sets the topic name for the consumer.
This method specifies the topic that the consumer will subscribe to. It is a required field and must be set before the consumer can be created.
§Parameters
topic: The name of the topic for the consumer. This should be a non-empty string that corresponds to an existing topic.
Sourcepub fn with_consumer_name(self, consumer_name: impl Into<String>) -> Self
pub fn with_consumer_name(self, consumer_name: impl Into<String>) -> Self
Sets the name of the consumer instance.
This method specifies the name to be assigned to the consumer. It is a required field and must be set before the consumer can be created.
§Parameters
consumer_name: The name for the consumer instance. This should be a non-empty string that uniquely identifies the consumer.
Sourcepub fn with_subscription(self, subscription_name: impl Into<String>) -> Self
pub fn with_subscription(self, subscription_name: impl Into<String>) -> Self
Sets the name of the subscription for the consumer.
This method specifies the subscription that the consumer will use. It is a required field and must be set before the consumer can be created.
§Parameters
subscription_name: The name of the subscription. This should be a non-empty string that identifies the subscription to which the consumer will be subscribed.
Sourcepub fn with_subscription_type(self, subscription_type: SubType) -> Self
pub fn with_subscription_type(self, subscription_type: SubType) -> Self
Sets the type of subscription for the consumer. This field is optional.
This method specifies the type of subscription that the consumer will use. The subscription type determines how messages are distributed to consumers that share the same subscription.
§Parameters
sub_type: The type of subscription. This should be one of the following:SubType::Exclusive: The consumer exclusively receives all messages for the subscription.SubType::Shared: Messages are distributed among multiple consumers sharing the same subscription. Default if not specified.SubType::FailOver: Only one consumer receives messages, and if it fails, another consumer takes over.
Sourcepub fn build(self) -> Consumer
pub fn build(self) -> Consumer
Creates a new Consumer instance using the settings configured in the ConsumerBuilder.
This method performs validation to ensure that all required fields are set before creating the Consumer. Once validation is successful, it constructs and returns a new Consumer instance configured with the specified settings.
§Returns
- A
Consumerinstance if the builder configuration is valid and the consumer is created successfully.
Trait Implementations§
Source§impl Clone for ConsumerBuilder
impl Clone for ConsumerBuilder
Source§fn clone(&self) -> ConsumerBuilder
fn clone(&self) -> ConsumerBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !Freeze for ConsumerBuilder
impl !RefUnwindSafe for ConsumerBuilder
impl Send for ConsumerBuilder
impl Sync for ConsumerBuilder
impl Unpin for ConsumerBuilder
impl !UnwindSafe for ConsumerBuilder
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request