use std::env; use std::sync::Arc; use std::time::Duration; use anyhow; use zookeeper; use anyhow::Context; use jotty; use jotty::HandlerResult; struct NoopWatcher; impl zookeeper::Watcher for NoopWatcher { fn handle(&self, _ev: zookeeper::WatchedEvent) {} } fn zk_server_urls() -> String { let key = "ZOOKEEPER_SERVERS"; match env::var(key) { Ok(val) => val, Err(_) => "localhost:2181".to_string(), } } fn main() -> anyhow::Result<()> { // env_logger::init(); // // let zk_urls = zk_server_urls(); // let zk = zookeeper::ZooKeeper::connect(&*zk_urls, Duration::from_millis(2500), NoopWatcher).unwrap(); // let zka = Arc::new(zk); // // let mut jotty = jotty::Builder::new("co.volf.jotty.testing".to_string()) // .executor(true) // .channels(12) // .build(zka).context("yp yp")?; // // // jotty.executor.register("echo", jotty::executor::mk_callback(|_id, ctx, _args, shared| { // println!("hello world {:?}", ctx); // std::thread::sleep(Duration::from_secs(1)); // shared.insert("my_key".to_string(), serde_json::Value::String("my_string".to_string())); // HandlerResult::Exit(0) // })); // // // // jotty.executor.run(); // // // // // std::thread::sleep(Duration::from_secs(900)); // Ok(()) }