datum-mq 0.10.10

Kafka sources and sinks for Datum streams, with native and rdkafka backends
Documentation
#![forbid(unsafe_code)]
//! Kafka sources and sinks for Datum streams.
//!
//! `datum-mq` is an additive Datum satellite crate with Tokio-native Kafka
//! consumer and producer backends by default. Its default-on `rdkafka` Cargo
//! feature adds selectable librdkafka compatibility backends. Disable default
//! features to remove `rdkafka`, `rdkafka-sys`, and librdkafka's C/CMake build.
//! The native rustls TLS path still compiles `aws-lc-rs`/`aws-lc-sys`, whose
//! build uses CMake.
//!
//! The consumer's shipped offset-commit guarantee is at-least-once.
//! [`KafkaSource::committable`] emits a [`datum::SourceWithContext`] whose
//! context is a [`KafkaOffset`]; downstream code commits that offset only after
//! its own checkpoint/side effect succeeds.
//! [`KafkaSink`] uses the native producer by default, and its materialized
//! [`KafkaProducerControl`] drains final acknowledgements before shutdown. The
//! native producer enables idempotence by default: it negotiates a producer
//! id/epoch and uses per-partition sequences so the broker deduplicates a
//! retried batch. Set `enable.idempotence=false` to opt out explicitly. The
//! pipeline remains bounded and partition ordered.
//! Kafka transactions and consume-transform-produce EOS are deferred.

mod config;
mod error;
mod metrics;
mod native;
mod offset;
#[doc(hidden)]
pub mod profile;
mod record;
mod sink;
mod source;

pub use config::{
    CommitPolicy, KafkaConfig, KafkaConsumerBackend, KafkaConsumerSettings, KafkaProducerBackend,
    KafkaProducerSettings, Offset, Subscription, TopicPartitionOffset,
};
pub use error::{MqError, MqResult};
pub use metrics::{KafkaMetrics, KafkaMetricsSnapshot};
pub use offset::{KafkaBatchOffset, KafkaOffset, KafkaOffsetBatch, OffsetCommit, TopicPartition};
pub use record::{ConsumerRecord, KafkaHeader, KafkaTimestamp, ProducerRecord};
pub use sink::{KafkaProducerControl, KafkaSink};
pub use source::{KafkaControl, KafkaPayloadBatch, KafkaPayloadRecord, KafkaSource};

/// The `datum-mq` crate version.
pub const VERSION: &str = env!("CARGO_PKG_VERSION");

/// Benchmark-only shims exposed for the criterion harness (a separate crate that
/// otherwise sees only the public API). Gated behind the internal, off-by-default
/// `bench-internals` feature so it is not part of the crates.io API surface.
#[cfg(feature = "bench-internals")]
#[doc(hidden)]
pub mod bench_support {
    pub use crate::native::bench_encode_produce_batch;
}

#[cfg(feature = "rdkafka")]
pub(crate) const fn consumer_rdkafka_hint() -> &'static str {
    "select KafkaConsumerBackend::Rdkafka"
}

#[cfg(not(feature = "rdkafka"))]
pub(crate) const fn consumer_rdkafka_hint() -> &'static str {
    "enable the datum-mq Cargo feature `rdkafka` and select KafkaConsumerBackend::Rdkafka"
}

#[cfg(feature = "rdkafka")]
pub(crate) const fn producer_rdkafka_hint() -> &'static str {
    "select KafkaProducerBackend::Rdkafka"
}

#[cfg(not(feature = "rdkafka"))]
pub(crate) const fn producer_rdkafka_hint() -> &'static str {
    "enable the datum-mq Cargo feature `rdkafka` and select KafkaProducerBackend::Rdkafka"
}