Skip to main content

Crate qm_kafka

Crate qm_kafka 

Source
Expand description

Kafka producer and topic management utilities.

This crate provides utilities for producing events to Kafka topics and managing Kafka topics and consumer groups.

§Features

  • Event Production: Produce structured events to Kafka topics
  • Topic Management: Create, delete, and ensure topics exist
  • Consumer Group Management: List and clean up consumer groups
  • Configuration: Environment-based configuration

§Usage

```ignore use qm_kafka::{Producer, Config, EventNs, EventType};

#[tokio::main] async fn main() -> anyhow::Result<()> { let producer = Producer::new()?; producer.create_event( &EventNs::User, “user”, “created”, serde_json::json!({“id”: “123”, “name”: “John”}) ).await?; Ok(()) } ```

§Environment Variables

VariableDescriptionDefault
KAFKA_HOSTKafka broker host127.0.0.1
KAFKA_PORTKafka broker port9092
KAFKA_ADDRESSFull broker address<host>:<port>
KAFKA_TOPIC_MUTATION_EVENTSMutation events topicqm_mutation_events
KAFKA_CONSUMER_GROUP_MUTATION_EVENTS_PREFIXConsumer group prefixqm_consumer_group

Modules§

config
Configuration module.
producer
Producer module for creating Kafka events.
topics
Topics module for managing Kafka topics.