Skip to content

Commit

Permalink
clean up some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ahopkins committed Mar 5, 2019
1 parent 8bba79b commit 146dec1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 22 deletions.
14 changes: 1 addition & 13 deletions src/lib/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@ impl Request {
None => return Err(format!("PUSH needs a channel_id")),
};
match parts.next() {
// Some("RETRIEVE") => {
// let key = match parts.next() {
// Some(key) => key,
// None => return Err(format!("GET must be followed by a key")),
// };
// if parts.next().is_some() {
// return Err(format!("GET's key must not be followed by anything"));
// }
// Ok(Request::Retrieve {
// key: key.to_string(),
// })
// }
Some("PUSH") => {
let temp = match parts.next() {
Some(temp) => temp,
Expand Down Expand Up @@ -115,7 +103,7 @@ impl Response {
let serialized = serde_json::to_string(message).unwrap();
format!("OK {}", serialized)
},
Response::Done { } => format!("OK Done"),
Response::Done { } => format!("OK Done."),
Response::Error { ref message } => format!("ER {}", message),
}
}
Expand Down
19 changes: 10 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ use std::cmp;
use blob_uuid;

const MAXIMUM: usize = 10;
const BACKUP_INTERVAL: u64 = 3; // 5 minutes in seconds
const BACKUP_INTERVAL: u64 = 0; // seconds


fn main() -> Result<(), Box<std::error::Error>> {
let addr = env::args().nth(1).unwrap_or("127.0.0.1:6363".to_string());
Expand All @@ -39,13 +40,13 @@ fn main() -> Result<(), Box<std::error::Error>> {

let db = state::create_db();

let start_backup = Interval::new(Instant::now(), Duration::from_millis(BACKUP_INTERVAL * 1_000))
let start_backup = Interval::new(Instant::now(), Duration::from_millis(BACKUP_INTERVAL * 1_000 + 1))
.for_each(|_| {
let address = "127.0.0.1:6363".parse().expect("Unable to parse address");
let connection = TcpStream::connect(&address);
connection.and_then(|socket| {
let (rx, mut tx) = socket.split();
tx.poll_write(b"foo RECENT");
let (_, mut tx) = socket.split();
tx.poll_write(b"foo RECENT").expect("Unable to send to TCP connection");
return Ok(());
});

Expand Down Expand Up @@ -160,7 +161,6 @@ fn main() -> Result<(), Box<std::error::Error>> {
let channel = _channel.unwrap();
let data = channel.data.lock().unwrap();
let index = channel.index.lock().unwrap();
let message = &data[0];

let path = format!("/mnt/c/Users/Adam/Projects/merkava/.data/{}", channel_id);
match create_dir_all(path.clone()) {
Expand All @@ -170,11 +170,11 @@ fn main() -> Result<(), Box<std::error::Error>> {

let data_file = format!("{}/data.mrkv", path);
let writer = File::create(data_file).unwrap();
serialize_into(writer, &data.clone());
serialize_into(writer, &data.clone()).expect("Unable to write to file");

let index_file = format!("{}/index.mrkv", path);
let writer = File::create(index_file).unwrap();
serialize_into(writer, &index.clone());
serialize_into(writer, &index.clone()).expect("Unable to write to file");

types::Response::Done {}
}
Expand All @@ -192,10 +192,11 @@ fn main() -> Result<(), Box<std::error::Error>> {
});

tokio::run(lazy(|| {
tokio::spawn(start_backup);
if BACKUP_INTERVAL > 0 {
tokio::spawn(start_backup);
}
tokio::spawn(done);
Ok(())
}));
// tokio::run(done);
Ok(())
}
File renamed without changes.
Empty file added tests/data/.gitkeep
Empty file.
6 changes: 6 additions & 0 deletions tests/test_commands.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#[cfg(test)]

#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}

0 comments on commit 146dec1

Please sign in to comment.