use std::env; use std::sync::Arc; use std::time::Duration; 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(_) => "gpn1.lab.volf.co: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) // .manager(true) // .channels(12) // .build(zka).context("yo yo")?; // // 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(id.to_string(), serde_json::Value::String("I say hello!".to_string())); // HandlerResult::Exit(0) // })); // // // jotty.manager.run(); // jotty.executor.run(); // // std::thread::sleep(Duration::from_secs(300)); // Ok(()) }