Minor formatting changes and last context read fix
This commit is contained in:
parent
a31ed0a4e5
commit
8ebc4abc19
|
@ -7,7 +7,7 @@ use sled::IVec;
|
|||
|
||||
pub struct DB {
|
||||
db: sled::Db,
|
||||
}
|
||||
}
|
||||
|
||||
impl DB {
|
||||
pub fn write_context(&mut self, context: lox_context::LoxServerContext) {
|
||||
|
@ -115,7 +115,7 @@ fn compute_startdate_string(date_range_end: String) -> Option<DateTime<Utc>> {
|
|||
|
||||
fn use_last_context(lox_db: sled::Db) -> lox_context::LoxServerContext {
|
||||
let ivec_context = lox_db.last().unwrap().unwrap();
|
||||
let ivec_date: String = serde_json::from_slice(&ivec_context.0).unwrap();
|
||||
let ivec_date: String = String::from_utf8(ivec_context.0.to_vec()).unwrap();
|
||||
println!("Using last context with date: {:?}", ivec_date);
|
||||
serde_json::from_slice(&ivec_context.1).unwrap()
|
||||
}
|
||||
|
|
|
@ -121,7 +121,6 @@ async fn rdsys_request(rtype: ResourceInfo, tx: mpsc::Sender<Vec<Resource>>) {
|
|||
.await
|
||||
.unwrap();
|
||||
tx.send(resources).await.unwrap();
|
||||
sleep(Duration::from_secs(30)).await;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,7 +135,7 @@ async fn rdsys_bridge_parser(
|
|||
}
|
||||
}
|
||||
|
||||
// Parse Bridges receives a ResourceDiff from rdsys_sender and sends it to the
|
||||
// Parse Bridges receives a Vec<Resource> from rdsys_sender and sends it to the
|
||||
// Context Manager to be parsed and added to the BridgeDB
|
||||
async fn parse_bridges(rdsys_tx: mpsc::Sender<Command>, mut rx: mpsc::Receiver<Vec<Resource>>) {
|
||||
loop {
|
||||
|
@ -283,7 +282,7 @@ async fn main() {
|
|||
});
|
||||
|
||||
let (tx, rx) = mpsc::channel(32);
|
||||
let rdsys_stream_handler = spawn(async { rdsys_stream(config.rtype, tx, kill_stream).await });
|
||||
let rdsys_request_handler = spawn(async { rdsys_stream(config.rtype, tx, kill_stream).await });
|
||||
|
||||
let rdsys_resource_receiver =
|
||||
spawn(async { rdsys_bridge_parser(rdsys_tx, rx, kill_parser).await });
|
||||
|
@ -313,7 +312,7 @@ async fn main() {
|
|||
eprintln!("server error: {}", e);
|
||||
}
|
||||
future::join_all([
|
||||
rdsys_stream_handler,
|
||||
rdsys_request_handler,
|
||||
rdsys_resource_receiver,
|
||||
context_manager,
|
||||
shutdown_handler,
|
||||
|
|
|
@ -50,7 +50,10 @@ pub fn parse_into_buckets(
|
|||
let mut bucket = [BridgeLine::default(); MAX_BRIDGES_PER_BUCKET];
|
||||
let mut leftovers: Vec<BridgeLine> = Vec::new();
|
||||
for bridgeline in bridgelines.clone() {
|
||||
println!("Added bridge with fingerprint: {:?}", bridgeline.uid_fingerprint);
|
||||
println!(
|
||||
"Added bridge with fingerprint: {:?}",
|
||||
bridgeline.uid_fingerprint
|
||||
);
|
||||
if count < MAX_BRIDGES_PER_BUCKET {
|
||||
bucket[count] = bridgeline;
|
||||
count += 1;
|
||||
|
|
|
@ -262,7 +262,8 @@ pub async fn start_stream(
|
|||
Ok(ResourceStream::new(rx))
|
||||
}
|
||||
|
||||
pub async fn request_resources( api_endpoint: String,
|
||||
pub async fn request_resources(
|
||||
api_endpoint: String,
|
||||
name: String,
|
||||
token: String,
|
||||
resource_types: Vec<String>,
|
||||
|
@ -283,7 +284,8 @@ pub async fn request_resources( api_endpoint: String,
|
|||
.header("Authorization", &auth_value)
|
||||
.body(json)
|
||||
.send()
|
||||
.await.unwrap();
|
||||
.await
|
||||
.unwrap();
|
||||
match response.status() {
|
||||
reqwest::StatusCode::OK => {
|
||||
fetched_resources = match response.json::<Vec<proto::Resource>>().await {
|
||||
|
@ -291,9 +293,7 @@ pub async fn request_resources( api_endpoint: String,
|
|||
Err(e) => Err(Error::Reqwest(e)),
|
||||
};
|
||||
}
|
||||
other => {
|
||||
fetched_resources = Err(Error::String(other))
|
||||
}
|
||||
other => fetched_resources = Err(Error::String(other)),
|
||||
};
|
||||
fetched_resources
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue