| Crates.io | kafka-remapper-core |
| lib.rs | kafka-remapper-core |
| version | 0.5.6 |
| created_at | 2025-12-19 09:06:12.044138+00 |
| updated_at | 2026-01-08 14:20:06.029836+00 |
| description | Core library for Kafka partition remapping proxy |
| homepage | https://github.com/osodevops/kafka-partition-remapper |
| repository | https://github.com/osodevops/kafka-partition-remapper |
| max_upload_size | |
| id | 1994437 |
| size | 599,927 |
Core library for building Kafka partition remapping proxies. This library provides the foundational components for transparently remapping virtual Kafka partitions to physical partitions.
kafka-protocol craterustls (mTLS supported)tokio for high-performance async I/OAdd to your Cargo.toml:
[dependencies]
kafka-remapper-core = "0.5"
tokio = { version = "1", features = ["full"] }
use kafka_remapper_core::config::ProxyConfig;
// Load configuration from YAML file
let config = ProxyConfig::from_file("config.yaml")?;
// Or parse from string
let yaml = r#"
listen:
address: "0.0.0.0:9092"
kafka:
bootstrap_servers:
- "kafka:9092"
mapping:
virtual_partitions: 100
physical_partitions: 10
"#;
let config = ProxyConfig::from_str(yaml)?;
use kafka_remapper_core::config::MappingConfig;
use kafka_remapper_core::remapper::PartitionRemapper;
let config = MappingConfig {
virtual_partitions: 100,
physical_partitions: 10,
offset_range: 1 << 40,
topics: Default::default(),
};
let remapper = PartitionRemapper::new(&config);
// Map virtual partition 42 to physical
let mapping = remapper.virtual_to_physical(42)?;
println!("Physical partition: {}", mapping.physical_partition); // 2
println!("Virtual group: {}", mapping.virtual_group); // 4
// Map with offset translation
let offset_mapping = remapper.virtual_to_physical_offset(42, 1000)?;
println!("Physical offset: {}", offset_mapping.physical_offset);
use kafka_remapper_core::broker::BrokerPool;
use kafka_remapper_core::config::KafkaConfig;
use std::sync::Arc;
let kafka_config = KafkaConfig {
bootstrap_servers: vec!["localhost:9092".to_string()],
..Default::default()
};
let pool = Arc::new(BrokerPool::new(kafka_config));
pool.connect().await?;
// Get connection to specific broker
let conn = pool.get_connection(0).await?;
| Module | Description |
|---|---|
config |
Configuration types (ProxyConfig, MappingConfig, etc.) |
error |
Error types (ProxyError, RemapError, AuthError, etc.) |
remapper |
Core partition/offset mapping logic |
broker |
Kafka broker connection pool and metadata management |
network |
TCP listener and Kafka protocol codec |
handlers |
Kafka protocol request handlers |
auth |
SASL authentication and principal extraction |
tls |
TLS client/server configuration |
metrics |
Prometheus metrics collection |
testing - Enables test utilities (MockBroker, ProxyTestHarness)oauthbearer-jwt - Enables JWT validation for OAUTHBEARER authenticationFor a ready-to-use proxy binary, see the kafka-partition-proxy CLI tool:
# Install via Homebrew
brew install osodevops/tap/kafka-partition-proxy
# Or download from releases
curl -LsSf https://github.com/osodevops/kafka-partition-remapper/releases/latest/download/kafka-remapper-cli-installer.sh | sh
Licensed under the Apache License, Version 2.0. See LICENSE for details.