datum-mq 0.10.5

Kafka sources and sinks for Datum streams, with native and rdkafka backends
Documentation
use datum::StreamError;
use thiserror::Error;

/// Result type used by `datum-mq`.
pub type MqResult<T> = Result<T, MqError>;

/// Kafka connector errors.
#[derive(Debug, Error)]
pub enum MqError {
    #[cfg(feature = "rdkafka")]
    #[error("Kafka client error: {0}")]
    Kafka(#[from] rdkafka::error::KafkaError),

    #[error("invalid Kafka configuration: {0}")]
    InvalidConfig(String),

    #[error("Kafka control handle is not available")]
    ControlUnavailable,

    #[error("Kafka assignment was lost for {topic}:{partition}; refusing to commit offset")]
    AssignmentLost { topic: String, partition: i32 },

    #[error("Kafka drain timed out")]
    DrainTimeout,

    #[error("Kafka producer delivery failed: {0}")]
    Delivery(String),

    #[error(
        "native Kafka producer delivery failed for {topic}:{partition}: {message} (broker code {code})"
    )]
    NativeDelivery {
        topic: String,
        partition: i32,
        code: i16,
        message: String,
    },

    #[error("native Kafka TLS handshake with broker {broker} failed: {message}")]
    NativeTls { broker: String, message: String },

    #[error("native Kafka SASL {mechanism} authentication with broker {broker} failed: {message}")]
    NativeSasl {
        broker: String,
        mechanism: String,
        message: String,
    },

    #[error("Kafka operation failed: {0}")]
    Failed(String),
}

impl From<MqError> for StreamError {
    fn from(error: MqError) -> Self {
        StreamError::Failed(error.to_string())
    }
}