extern crate couchbase;
extern crate futures;
use std::sync::Arc;
use std::thread;
use couchbase::Cluster;
use futures::Future;
use couchbase::document::BinaryDocument;
fn main() {
let cluster = Cluster::new("localhost").expect("Could not initialize Cluster");
let bucket = Arc::new(
cluster
.open_bucket("travel-sample", None)
.expect("Could not open Bucket"),
);
let thread_count = 8;
let mut threads = vec![];
for i in 0..thread_count {
let b = bucket.clone();
threads.push(thread::spawn(move || {
let id = format!("airport_{}", i + 1254);
println!(
"Thread {:?} found:\n\t{:?}",
i,
b.get::<BinaryDocument, _>(id).wait().unwrap()
);
}));
}
for child in threads {
let _ = child.join();
}
}