Skip to content

Commit

Permalink
docs(kafka): Add more module docs and fix typos in kafka crate (#2369)
Browse files Browse the repository at this point in the history
Add more docs into the `relay-kafka` crate and fix some typos.
  • Loading branch information
olksdr authored Aug 2, 2023
1 parent 32b87a4 commit 5b63e88
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
10 changes: 9 additions & 1 deletion relay-kafka/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//! Configuration primitives to configure the kafka producer and properly set up the connection.
//!
//! The configuration can be either;
//! - [`TopicAssignment::Primary`] - the main and default kafka configuration,
//! - [`TopicAssignment::Secondary`] - used to configure any additional kafka topic,
//! - [`TopicAssignment::Sharded`] - if we want to configure multiple kafka clusters,
//! we can create a mapping of the range of logical shards to the kafka configuration.

use std::collections::BTreeMap;

use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -250,7 +258,7 @@ impl TopicAssignment {
/// Get the kafka config for the current topic assignment.
///
/// # Errors
/// Returns [`ConfigError`] if the configuration for the current topic assignement is invalid.
/// Returns [`ConfigError`] if the configuration for the current topic assignment is invalid.
pub fn kafka_config<'a>(
&'a self,
default_config: &'a Vec<KafkaConfigParam>,
Expand Down
12 changes: 10 additions & 2 deletions relay-kafka/src/producer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//! This module contains the kafka producer related code.
//!
//! There are two different producers that are supported in Relay right now:
//! - [`SingleProducer`] - which sends all the messages to the defined kafka [`KafkaTopic`],
//! - [`ShardedProducer`] - which expects to have at least one shard configured, and depending on
//! the shard number the different messages will be sent to different topics using the configured
//! producer for the this exact shard.

#[cfg(debug_assertions)]
use std::cell::RefCell;
use std::collections::{BTreeMap, HashMap};
Expand Down Expand Up @@ -196,7 +204,7 @@ impl KafkaClient {
}
}

/// Helper structure responsable for building the actual [`KafkaClient`].
/// Helper structure responsible for building the actual [`KafkaClient`].
#[derive(Default)]
pub struct KafkaClientBuilder {
reused_producers: BTreeMap<Option<String>, Arc<ThreadedProducer>>,
Expand Down Expand Up @@ -318,7 +326,7 @@ impl fmt::Debug for KafkaClientBuilder {
}
}

/// This object containes the Kafka producer variants for single and sharded configurations.
/// This object contains the Kafka producer variants for single and sharded configurations.
#[derive(Debug)]
enum Producer {
/// Configuration variant for the single kafka producer.
Expand Down

0 comments on commit 5b63e88

Please sign in to comment.