extern crate kinetic_protobuf as kp; extern crate tokio_kinetic as kinetic; extern crate futures; extern crate tokio_core; extern crate tokio_proto; extern crate tokio_service; extern crate env_logger; use futures::Future; use tokio_core::reactor::Core; use tokio_service::Service; use std::net::SocketAddr; use std::net::IpAddr; use std::env; use kinetic::connection::Options; use kinetic::connection::Connection; use kinetic::request::Request; fn addr() -> Result { match (env::args().nth(1), env::args().nth(2)) { (Some(ip), Some(port)) => { let ip = ip.parse::().map_err(|_| ())?; let port = port.parse::().map_err(|_| ())?; Ok(SocketAddr::new(ip, port)) } _ => Err(()) } } fn main() { env_logger::init().unwrap(); let addr = match addr() { Ok(addr) => addr, _ => { let bin = env::args().nth(0).expect("expected 0th env arg"); println!("usage: {} [ip] [port]", bin); return; } }; let mut core = Core::new().unwrap(); let handle = core.handle(); let options = Options::new(1, b"asdfasdf".to_vec(), false); let done = Connection::with_options(&addr, &handle, options) .and_then(|conn| { conn.call(Request::put(b"key".to_vec())) .and_then(|_| { println!("received response"); Ok(()) }) }); match core.run(done) { Ok(_) => (), Err(err) => println!("err: {}", err) } }