use kinbox::FutureRecord;
use kinbox::config::{CommonConfig, WriteConfig};
use kinbox::writer::Writer;

#[tokio::main]
async fn main() {
    println!("{:?}", run().await);
}

async fn run() -> Result<(), kinbox::KafkaError> {
    let mut write_config = WriteConfig::new();
    write_config.set_brokers(&["192.168.102.8:9092"]);

    let writer = Writer::new(&write_config)?;
    println!(
        "{:?}",
        writer
            .write(
                FutureRecord::to("default.rpc-test")
                    .payload("wo that is one data")
                    .partition(2)
                    .key("name1")
                    .headers(kinbox::OwnedHeaders::new().insert(kinbox::Header {
                        key: "header1",
                        value: Some("value1"),
                    }))
            )
            .await?
    );

    Ok(())
}
