Skip to content

Commit

Permalink
SEND_CACHE_HASH_PERIOD=120
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeguglielmo committed Jun 20, 2023
1 parent 9fc2ea4 commit daf119b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dht-cache/src/domocache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub enum DomoEvent {
}

// period at which we send messages containing our cache hash
const SEND_CACHE_HASH_PERIOD: u8 = 5;
const SEND_CACHE_HASH_PERIOD: u8 = 120;

#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
pub struct DomoCacheElement {
Expand Down
2 changes: 2 additions & 0 deletions src/domobroker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::websocketmessage::{
};

use serde_json::json;
use crate::utils::get_epoch_ms;

pub struct DomoBroker {
pub domo_cache: DomoCache,
Expand Down Expand Up @@ -259,6 +260,7 @@ impl DomoBroker {
deleted: m.deleted,
},
);
println!("SENT DATA ON WS {}", get_epoch_ms());
DomoEvent::PersistentData(m2)
}
Ok(DomoEvent::VolatileData(m)) => {
Expand Down
6 changes: 4 additions & 2 deletions src/webapimanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use crate::websocketmessage::{
use crate::{restmessage, utils};

use std::net::TcpListener;
use crate::utils::get_epoch_ms;

pub struct WebApiManager {
// rest api listening port
Expand Down Expand Up @@ -61,7 +62,7 @@ impl WebApiManager {
_ = socket::setsockopt(listener.as_raw_fd(), ReuseAddr, &true);
}

let (tx_rest, rx_rest) = mpsc::channel(32);
let (tx_rest, rx_rest) = mpsc::channel(64);

let tx_get_all = tx_rest.clone();

Expand Down Expand Up @@ -200,9 +201,10 @@ impl WebApiManager {
responder: tx_resp,
};

println!("Sending POST REQ {}", get_epoch_ms());
tx_rest.send(m).await.unwrap();

let resp = rx_resp.await.unwrap();
println!("Received POST RESP {}", get_epoch_ms());

match resp {
Ok(resp) => (StatusCode::OK, Json(resp)),
Expand Down

0 comments on commit daf119b

Please sign in to comment.