pub enum KafkaError {
Show 17 variants
Connection {
message: String,
broker: String,
},
Consumption {
message: String,
topic: String,
partition: Option<i32>,
offset: Option<i64>,
},
Production {
message: String,
topic: String,
partition: Option<i32>,
},
Serialization {
message: String,
context: Option<String>,
},
Deserialization {
message: String,
context: Option<String>,
payload_sample: Option<Vec<u8>>,
},
InvalidConfiguration {
message: String,
field: Option<String>,
},
OffsetCommit {
message: String,
topic: String,
partition: i32,
offset: i64,
},
GroupCoordination {
message: String,
group_id: String,
},
PartitionAssignment {
message: String,
topics: Vec<String>,
},
AuthError {
message: String,
protocol: String,
},
IoError {
message: String,
source: Option<Error>,
},
Timeout {
operation: String,
timeout_ms: u64,
},
TopicMetadata {
message: String,
topic: String,
},
PartitionNotFound {
topic: String,
partition: i32,
},
ResourceExhausted {
message: String,
resource: String,
},
KafkaClient {
message: String,
code: Option<i32>,
},
Other(String),
}Expand description
Comprehensive error type for Kafka operations.
This enum covers all possible error scenarios when working with Kafka, providing detailed context for debugging and error handling.
§Examples
use processor::kafka::error::{KafkaError, Result};
fn connect_to_kafka() -> Result<()> {
// Simulate connection error
Err(KafkaError::Connection {
message: "Failed to connect to broker".to_string(),
broker: "localhost:9092".to_string(),
})
}
match connect_to_kafka() {
Ok(_) => println!("Connected successfully"),
Err(KafkaError::Connection { message, broker }) => {
eprintln!("Connection error to {}: {}", broker, message);
}
Err(e) => eprintln!("Other error: {}", e),
}Variants§
Connection
Error establishing connection to Kafka broker.
Fields
Consumption
Error during message consumption.
Fields
Production
Error during message production.
Fields
Serialization
Error during serialization of messages.
Fields
Deserialization
Error during deserialization of messages.
Fields
InvalidConfiguration
Configuration validation error.
Fields
OffsetCommit
Error committing offsets.
Fields
GroupCoordination
Error during consumer group coordination.
Fields
PartitionAssignment
Error during partition assignment.
Fields
AuthError
Authentication or authorization error.
Fields
IoError
Network or I/O error.
Fields
Timeout
Timeout error during Kafka operations.
Fields
TopicMetadata
Error related to topic metadata.
PartitionNotFound
Error when a topic partition doesn’t exist.
ResourceExhausted
Error when reaching resource limits.
Fields
KafkaClient
Error from the underlying rdkafka library.
Other(String)
Generic error for cases not covered by specific variants.
Implementations§
Source§impl KafkaError
impl KafkaError
Sourcepub fn connection(message: impl Into<String>, broker: impl Into<String>) -> Self
pub fn connection(message: impl Into<String>, broker: impl Into<String>) -> Self
Create a connection error.
Sourcepub fn consumption(
message: impl Into<String>,
topic: impl Into<String>,
partition: Option<i32>,
offset: Option<i64>,
) -> Self
pub fn consumption( message: impl Into<String>, topic: impl Into<String>, partition: Option<i32>, offset: Option<i64>, ) -> Self
Create a consumption error.
Sourcepub fn production(
message: impl Into<String>,
topic: impl Into<String>,
partition: Option<i32>,
) -> Self
pub fn production( message: impl Into<String>, topic: impl Into<String>, partition: Option<i32>, ) -> Self
Create a production error.
Sourcepub fn serialization(
message: impl Into<String>,
context: Option<String>,
) -> Self
pub fn serialization( message: impl Into<String>, context: Option<String>, ) -> Self
Create a serialization error.
Sourcepub fn deserialization(
message: impl Into<String>,
context: Option<String>,
payload_sample: Option<Vec<u8>>,
) -> Self
pub fn deserialization( message: impl Into<String>, context: Option<String>, payload_sample: Option<Vec<u8>>, ) -> Self
Create a deserialization error.
Sourcepub fn invalid_config(message: impl Into<String>, field: Option<String>) -> Self
pub fn invalid_config(message: impl Into<String>, field: Option<String>) -> Self
Create an invalid configuration error.
Sourcepub fn offset_commit(
message: impl Into<String>,
topic: impl Into<String>,
partition: i32,
offset: i64,
) -> Self
pub fn offset_commit( message: impl Into<String>, topic: impl Into<String>, partition: i32, offset: i64, ) -> Self
Create an offset commit error.
Sourcepub fn group_coordination(
message: impl Into<String>,
group_id: impl Into<String>,
) -> Self
pub fn group_coordination( message: impl Into<String>, group_id: impl Into<String>, ) -> Self
Create a group coordination error.
Sourcepub fn partition_assignment(
message: impl Into<String>,
topics: Vec<String>,
) -> Self
pub fn partition_assignment( message: impl Into<String>, topics: Vec<String>, ) -> Self
Create a partition assignment error.
Sourcepub fn auth_error(
message: impl Into<String>,
protocol: impl Into<String>,
) -> Self
pub fn auth_error( message: impl Into<String>, protocol: impl Into<String>, ) -> Self
Create an authentication/authorization error.
Sourcepub fn topic_metadata(
message: impl Into<String>,
topic: impl Into<String>,
) -> Self
pub fn topic_metadata( message: impl Into<String>, topic: impl Into<String>, ) -> Self
Create a topic metadata error.
Sourcepub fn partition_not_found(topic: impl Into<String>, partition: i32) -> Self
pub fn partition_not_found(topic: impl Into<String>, partition: i32) -> Self
Create a partition not found error.
Sourcepub fn resource_exhausted(
message: impl Into<String>,
resource: impl Into<String>,
) -> Self
pub fn resource_exhausted( message: impl Into<String>, resource: impl Into<String>, ) -> Self
Create a resource exhausted error.
Sourcepub fn kafka_client(message: impl Into<String>, code: Option<i32>) -> Self
pub fn kafka_client(message: impl Into<String>, code: Option<i32>) -> Self
Create a Kafka client error.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Check if the error is retryable.
Returns true if the operation that caused this error can be retried.
Sourcepub fn is_fatal(&self) -> bool
pub fn is_fatal(&self) -> bool
Check if the error is fatal and requires system shutdown.
Returns true if the error indicates an unrecoverable state.
Sourcepub fn severity(&self) -> ErrorSeverity
pub fn severity(&self) -> ErrorSeverity
Get error severity level.
Returns a severity level suitable for logging and monitoring.
Trait Implementations§
Source§impl Debug for KafkaError
impl Debug for KafkaError
Source§impl Display for KafkaError
impl Display for KafkaError
Source§impl Error for KafkaError
impl Error for KafkaError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<Error> for KafkaError
impl From<Error> for KafkaError
Source§impl From<Error> for KafkaError
impl From<Error> for KafkaError
Source§impl From<KafkaError> for KafkaError
impl From<KafkaError> for KafkaError
Source§fn from(err: KafkaError) -> Self
fn from(err: KafkaError) -> Self
Auto Trait Implementations§
impl Freeze for KafkaError
impl !RefUnwindSafe for KafkaError
impl Send for KafkaError
impl Sync for KafkaError
impl Unpin for KafkaError
impl !UnwindSafe for KafkaError
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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 moreSource§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::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.