Skip to content

Commit

Permalink
update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cploutarchou committed Oct 21, 2023
1 parent ee3673e commit 7db99e0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tiny_kafka"
version = "1.0.1"
version = "1.0.2"
authors = ["Christos Ploutarchou <cploutarchou@gmail.com>"]
edition = "2021"
description = "A tiny Kafka client library with producer and consumer functionalities."
Expand Down
4 changes: 4 additions & 0 deletions src/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct ReceivedMessage {
///
/// ```no_run
/// use std::collections::HashMap;
/// use tiny_kafka::consumer::KafkaConsumer;
/// let mut consumer = KafkaConsumer::new("localhost:9092", "my_group", "my_topic");
///
/// // Consume messages in a loop
Expand Down Expand Up @@ -61,6 +62,7 @@ impl KafkaConsumer {
/// Basic usage:
///
/// ```no_run
/// use tiny_kafka::consumer::KafkaConsumer;
/// let consumer = KafkaConsumer::new("localhost:9092", "my_group", "my_topic");
/// ```
pub fn new(brokers: &str, group_id: &str, topic_name: &str) -> Self {
Expand Down Expand Up @@ -94,6 +96,7 @@ impl KafkaConsumer {
/// Basic usage:
///
/// ```no_run
/// use tiny_kafka::consumer::KafkaConsumer;
/// tokio::spawn(async move {
/// let consumer = KafkaConsumer::new("localhost:9092", "my_group", "my_topic");
/// if let Some(msg) = consumer.poll().await {
Expand Down Expand Up @@ -155,6 +158,7 @@ impl KafkaConsumer {
///
/// ```no_run
/// use std::collections::HashMap;
/// use tiny_kafka::consumer::KafkaConsumer;
/// let mut consumer = KafkaConsumer::new("localhost:9092", "my_group", "my_topic");
/// let mut new_configs = HashMap::new();
/// new_configs.insert("auto.offset.reset".to_string(), "earliest".to_string());
Expand Down
10 changes: 8 additions & 2 deletions src/producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use std::time::Duration;
/// Represents a message with a key and value to be sent to Kafka.
#[derive(Serialize)]
pub struct Message {
key: String,
value: String,
pub key: String,
pub value: String,
}

impl Message {
Expand All @@ -25,6 +25,7 @@ impl Message {
/// # Examples
///
/// ```
/// use tiny_kafka::producer::Message;
/// let msg = Message::new("key1", "value1");
/// assert_eq!(msg.key, "key1");
/// assert_eq!(msg.value, "value1");
Expand Down Expand Up @@ -53,6 +54,8 @@ impl KafkaProducer {
///
/// ```no_run
/// // Initialize a KafkaProducer without any custom configurations
/// use std::collections::HashMap;
/// use tiny_kafka::producer::KafkaProducer;
/// let producer = KafkaProducer::new("localhost:9092", None);
///
/// // With custom configurations
Expand Down Expand Up @@ -90,6 +93,7 @@ impl KafkaProducer {
/// # Examples
///
/// ```no_run
/// use tiny_kafka::producer::{KafkaProducer, Message};
/// let producer = KafkaProducer::new("localhost:9092", None);
/// let msg = Message::new("key1", "value1");
///
Expand Down Expand Up @@ -137,6 +141,8 @@ impl KafkaProducer {
/// # Examples
///
/// ```no_run
/// use std::collections::HashMap;
/// use tiny_kafka::producer::KafkaProducer;
/// let mut producer = KafkaProducer::new("localhost:9092", None);
///
/// // Update producer configurations
Expand Down

0 comments on commit 7db99e0

Please sign in to comment.