kafka-remapper-core
Core library for building Kafka partition remapping proxies. This library provides the foundational components for transparently remapping virtual Kafka partitions to physical partitions.
Features
- Partition Remapping: Map N virtual partitions to M physical partitions with automatic offset translation
- Protocol Handling: Full Kafka protocol support via
kafka-protocolcrate - TLS Support: Client and server TLS with
rustls(mTLS supported) - SASL Authentication: PLAIN, SCRAM-SHA-256, SCRAM-SHA-512, OAUTHBEARER
- Metrics: Built-in Prometheus metrics collection
- Async Runtime: Built on
tokiofor high-performance async I/O
Installation
Add to your Cargo.toml:
[]
= "0.5"
= { = "1", = ["full"] }
Usage
Configuration
use ProxyConfig;
// Load configuration from YAML file
let config = from_file?;
// 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 = from_str?;
Partition Remapping
use MappingConfig;
use PartitionRemapper;
let config = MappingConfig ;
let remapper = new;
// Map virtual partition 42 to physical
let mapping = remapper.virtual_to_physical?;
println!; // 2
println!; // 4
// Map with offset translation
let offset_mapping = remapper.virtual_to_physical_offset?;
println!;
Broker Connection Pool
use BrokerPool;
use KafkaConfig;
use Arc;
let kafka_config = KafkaConfig ;
let pool = new;
pool.connect.await?;
// Get connection to specific broker
let conn = pool.get_connection.await?;
Main Components
| 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 |
Feature Flags
testing- Enables test utilities (MockBroker,ProxyTestHarness)oauthbearer-jwt- Enables JWT validation for OAUTHBEARER authentication
Documentation
CLI Tool
For a ready-to-use proxy binary, see the kafka-partition-proxy CLI tool:
# Install via Homebrew
# Or download from releases
|
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.