Skip to content

Commit

Permalink
Move IndexWatcher logging level to debug (#96)
Browse files Browse the repository at this point in the history
* Move IndexWatcher logging level to debug

* Clean code up a bit

Reformat using rustfmt
  • Loading branch information
andrewbanchich authored and hntd187 committed Jan 16, 2019
1 parent dfbe870 commit d8b8ff0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
17 changes: 7 additions & 10 deletions src/bin/toshi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,9 @@ fn settings() -> Settings {
)
.get_matches();

if options.is_present("config") {
let cfg = options.value_of("config").unwrap();
Settings::new(cfg).expect("Invalid Config file")
} else {
Settings::from_args(&options)
match options.value_of("config") {
Some(v) => Settings::new(v).expect("Invalid configuration file"),
None => Settings::from_args(&options),
}
}

Expand All @@ -144,16 +142,15 @@ fn run(catalog: Arc<RwLock<IndexCatalog>>, settings: &Settings) -> impl Future<I
let commit_watcher = IndexWatcher::new(catalog.clone(), settings.auto_commit_duration);
future::Either::A(future::lazy(move || {
commit_watcher.start();

future::ok::<(), ()>(())
}))
} else {
future::Either::B(future::ok::<(), ()>(()))
};

let addr = format!("{}:{}", &settings.host, settings.port);
let bind: SocketAddr = addr.parse().expect("Failed to parse socket address");

let bind: SocketAddr = addr.parse().unwrap();
println!("{}", HEADER);

if settings.enable_clustering {
Expand All @@ -180,15 +177,15 @@ fn connect_to_consul(settings: &Settings) -> impl Future<Item = (), Error = ()>
.with_cluster_name(cluster_name)
.with_address(consul_address)
.build()
.unwrap();
.expect("Could not build Consul client.");

// Build future that will connect to consul and register the node_id
// Build future that will connect to Consul and register the node_id
consul_client
.register_cluster()
.and_then(move |_| cluster::read_node_id(settings_path_read.as_str()))
.then(|result| match result {
Ok(id) => {
let parsed_id = Uuid::parse_str(&id).expect("Parsed node ID is not a UUID");
let parsed_id = Uuid::parse_str(&id).expect("Parsed node ID is not a UUID.");
cluster::write_node_id(settings_path_write, parsed_id.to_hyphenated().to_string())
}

Expand Down
4 changes: 2 additions & 2 deletions src/commit.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::index::IndexCatalog;

use futures::{Future, Stream};
use log::info;
use log::debug;
use tokio::timer::Interval;

use std::{
Expand All @@ -28,7 +28,7 @@ impl IndexWatcher {
let writer = index.get_writer();
let current_ops = index.get_opstamp();
if current_ops == 0 {
info!("No update to index={}, opstamp={}", key, current_ops);
debug!("No update to index={}, opstamp={}", key, current_ops);
} else if let Ok(mut w) = writer.lock() {
w.commit().unwrap();
index.set_opstamp(0);
Expand Down

0 comments on commit d8b8ff0

Please sign in to comment.