pub struct Kafka {
pub brokers: Vec<String>,
pub topic: String,
/* private fields */
}Expand description
Kafka client configuration for audit message production.
The [FutureProducer] is lazily created on the first
call to Audit::produce_message and reused for all
subsequent calls via an internal OnceLock.
Fields§
§brokers: Vec<String>Bootstrap broker list, e.g. vec!["kafka.example.com:9092"].
topic: StringKafka topic that audit messages are published to.
Implementations§
Source§impl Kafka
impl Kafka
Sourcepub fn new(brokers: Vec<String>, topic: String) -> Self
pub fn new(brokers: Vec<String>, topic: String) -> Self
Create a new Kafka instance with the given broker
list and topic name.
The actual FutureProducer is built lazily on the first
produce_message call, so this constructor is cheap and
infallible.
§Examples
use manta_shared::common::kafka::Kafka;
let k = Kafka::new(
vec!["kafka1.example.com:9092".into(), "kafka2.example.com:9092".into()],
"manta-audit".into(),
);
assert_eq!(k.topic, "manta-audit");
assert_eq!(k.brokers.len(), 2);Trait Implementations§
Source§impl Audit for Kafka
impl Audit for Kafka
Source§async fn produce_message(&self, data: &[u8]) -> Result<(), MantaError>
async fn produce_message(&self, data: &[u8]) -> Result<(), MantaError>
Publish a single audit message payload. Implementations are
expected to be fire-and-forget — failures should be logged but
not propagated to the caller, since audit failures must not
abort the outer operation.
Source§impl<'de> Deserialize<'de> for Kafka
impl<'de> Deserialize<'de> for Kafka
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl !Freeze for Kafka
impl !RefUnwindSafe for Kafka
impl Send for Kafka
impl Sync for Kafka
impl Unpin for Kafka
impl !UnwindSafe for Kafka
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
Mutably borrows from an owned value. Read more