1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! ### `sea-streamer-kafka`: Kafka / Redpanda Backend
//!
//! This is the Kafka / Redpanda backend implementation for SeaStreamer.
//! This crate provides a comprehensive type system that makes working with Kafka easier and safer.
//!
//! First of all, all API (many are sync) are properly wrapped as async. Methods are also marked `&mut` to eliminate possible race conditions.
//!
//! `KafkaConsumerOptions` has typed parameters.
//!
//! `KafkaConsumer` allows you to `seek` to point in time, `rewind` to particular offset, and `commit` message read.
//!
//! `KafkaProducer` allows you to `await` a send `Receipt` or discard it if you are uninterested. You can also flush the Producer.
//!
//! `KafkaStreamer` allows you to flush all producers on `disconnect`.
//!
//! See [tests](https://github.com/SeaQL/sea-streamer/blob/main/sea-streamer-kafka/tests/consumer.rs) for an illustration of the stream semantics.
//!
//! This crate depends on [`rdkafka`](https://docs.rs/rdkafka),
//! which in turn depends on [librdkafka-sys](https://docs.rs/librdkafka-sys), which itself is a wrapper of
//! [librdkafka](https://docs.confluent.io/platform/current/clients/librdkafka/html/index.html).
//!
//! Configuration Reference: <https://kafka.apache.org/documentation/#configuration>

#![cfg_attr(docsrs, feature(doc_cfg))]
#![deny(missing_debug_implementations)]
#![doc(
    html_logo_url = "https://raw.githubusercontent.com/SeaQL/sea-streamer/main/docs/SeaQL icon.png"
)]

/// The default Kafka port number
pub const KAFKA_PORT: u16 = 9092;

/// The default timeout, if needed but unspecified
pub const DEFAULT_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(60);

#[cfg(all(feature = "runtime-async-std", feature = "runtime-tokio"))]
compile_error!("'runtime-async-std' and 'runtime-tokio' cannot be enabled at the same time");

mod cluster;
mod consumer;
mod error;
mod host;
mod producer;
mod runtime;
mod streamer;

use cluster::*;
pub use consumer::*;
pub use error::*;
pub use host::*;
pub use producer::*;
pub use runtime::*;
pub use streamer::*;

/// Re-export types from `rdkafka`
pub mod export {
    pub use rdkafka;
}

macro_rules! impl_into_string {
    ($name:ident) => {
        impl From<$name> for String {
            fn from(o: $name) -> Self {
                o.as_str().to_owned()
            }
        }
    };
}

pub(crate) use impl_into_string;