Struct rdkafka::client::Client

source ·
pub struct Client<C: ClientContext + 'static = DefaultClientContext> { /* private fields */ }
Expand description

A low-level rdkafka client.

This type is the basis of the consumers and producers in the consumer and producer modules, respectively.

Typically you do not want to construct a Client directly, but instead construct a consumer or producer. A Client can be used, however, when only access to cluster metadata and watermarks is required.

Implementations§

source§

impl<C: ClientContext + 'static> Client<C>

source

pub fn new( config: &ClientConfig, native_config: NativeClientConfig, rd_kafka_type: RDKafkaType, context: C ) -> KafkaResult<Client<C>>

Creates a new Client given a configuration, a client type and a context.

source

pub fn native_client(&self) -> &NativeClient

Returns a reference to the native rdkafka-sys client.

source

pub fn native_ptr(&self) -> *mut RDKafka

Returns a pointer to the native rdkafka-sys client.

source

pub fn context(&self) -> &Arc<C>

Returns a reference to the context.

source

pub fn fetch_metadata<T: Into<Timeout>>( &self, topic: Option<&str>, timeout: T ) -> KafkaResult<Metadata>

Returns the metadata information for the specified topic, or for all topics in the cluster if no topic is specified.

source

pub fn fetch_watermarks<T: Into<Timeout>>( &self, topic: &str, partition: i32, timeout: T ) -> KafkaResult<(i64, i64)>

Returns high and low watermark for the specified topic and partition.

source

pub fn fetch_cluster_id<T: Into<Timeout>>(&self, timeout: T) -> Option<String>

Returns the cluster identifier option or None if the cluster identifier is null

source

pub fn fetch_group_list<T: Into<Timeout>>( &self, group: Option<&str>, timeout: T ) -> KafkaResult<GroupList>

Returns the group membership information for the given group. If no group is specified, all groups will be returned.

source

pub fn fatal_error(&self) -> Option<(RDKafkaErrorCode, String)>

Returns the first fatal error set on this client instance, or None if no fatal error has occurred.

This function is intended to be used with idempotent producers, where some errors must logically be considered fatal to retain consistency.

Trait Implementations§

source§

impl<C: ClientContext + 'static> Drop for Client<C>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<C> Freeze for Client<C>

§

impl<C> RefUnwindSafe for Client<C>
where C: RefUnwindSafe,

§

impl<C> Send for Client<C>

§

impl<C> Sync for Client<C>

§

impl<C> Unpin for Client<C>

§

impl<C> UnwindSafe for Client<C>
where C: RefUnwindSafe,

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.

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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