#kafka #rdkafka #async

madsim-rdkafka

The rdkafka simulator on madsim

12 releases

0.4.4+0.34.0 Jun 24, 2025
0.4.3+0.34.0 Jan 9, 2025
0.4.2+0.34.0 May 13, 2024
0.3.4+0.34.0 Mar 22, 2024
0.2.8-alpha Sep 26, 2022

#402 in Asynchronous

Download history 1599/week @ 2025-09-28 620/week @ 2025-10-05 2686/week @ 2025-10-12 1212/week @ 2025-10-19 1382/week @ 2025-10-26 2175/week @ 2025-11-02 1862/week @ 2025-11-09 1186/week @ 2025-11-16 5363/week @ 2025-11-23 1902/week @ 2025-11-30 1585/week @ 2025-12-07 1291/week @ 2025-12-14 862/week @ 2025-12-21 528/week @ 2025-12-28 1533/week @ 2026-01-04 1174/week @ 2026-01-11

4,155 downloads per month

Apache-2.0

520KB
10K SLoC

madsim-rdkafka

Crate Docs

The rdkafka simulator on madsim. Mirrors rdkafka v0.34.0 and librdkafka 2.3.0.

Usage

Replace all rdkafka entries in your Cargo.toml:

[dependencies]
rdkafka = { version = "0.4", package = "madsim-rdkafka" }

API Modification

This crate roughly follows the rdkafka API but is NOT exactly the same.

The following functions are modified to be async:

  • FromClientConfig::from_config
  • FromClientConfigAndContext::from_config_and_context
  • ClientConfig::create
  • ClientConfig::create_with_context
  • Client::fetch_metadata[^1]
  • Client::fetch_watermarks[^1]
  • Client::fetch_group_list[^1]
  • Consumer::seek
  • Consumer::seek_partitions
  • Consumer::commit
  • Consumer::commit_consumer_state
  • Consumer::commit_message
  • Consumer::committed
  • Consumer::committed_offsets
  • Consumer::offsets_for_timestamp
  • Consumer::offsets_for_times[^1]
  • Consumer::fetch_metadata[^1]
  • Consumer::fetch_watermarks[^1]
  • Consumer::fetch_group_list[^1]
  • Producer::flush
  • Producer::init_transactions
  • Producer::send_offsets_to_transaction
  • Producer::commit_transaction
  • Producer::abort_transaction

[^1]: wrapped in tokio::task::spawn_blocking

The associated constant ClientContext::ENABLE_REFRESH_OAUTH_TOKEN is changed to a function in order to make the trait object-safe.

DNS Resolution

This crate has cherry-picked a commit from Materialize to support rewriting broker addresses.

A new method is added to ClientContext:

  • ClientContext::rewrite_broker_addr

Dependencies

~14–32MB
~389K SLoC