use kinbox::config::CommonConfig;
use kinbox::inbox::Inbox;

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

async fn run() -> Result<(), kinbox::KafkaError> {
    let mut cfg = kinbox::config::ClientConfig::new();
    cfg.set_brokers(&["192.168.102.8:9092"]);
    let inbox = Inbox::new(&cfg)?;
    println!(
        "delete inbox: {:?}",
        inbox.delete_inbox("default.rpc-test").await?
    );

    tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;

    println!(
        "create inbox: {:?}",
        inbox
            .create_inbox("default.rpc-test", kinbox::inbox::CreateOption::new(3, 1))
            .await?
    );

    tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;

    println!("list: {:?}", kinbox::list::List::new(&cfg)?.list_inboxes()?);

    println!("adjusting inbox: {:?}", adjust_inbox(&inbox).await?);

    Ok(())
}

async fn adjust_inbox(inbox: &Inbox) -> Result<(), kinbox::KafkaError> {
    println!(
        "adjust inbox: {:?}",
        inbox.adjust_inbox("default.rpc-test", 1).await?
    );
    Ok(())
}
