-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add someip statistics api to unbound session
Showing
6 changed files
with
418 additions
and
40 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 33 additions & 38 deletions
71
application/apps/indexer/session/src/unbound/commands/someip.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,39 @@ | ||
use super::CommandOutcome; | ||
use crate::{events::ComputationError, unbound::signal::Signal}; | ||
use std::path::Path; | ||
|
||
use parsers::someip::{read_someip_statistic_from_pcapng, SomeipStatistic}; | ||
|
||
pub fn get_someip_statistic( | ||
_files: Vec<String>, | ||
_signal: Signal, | ||
files: Vec<String>, | ||
signal: Signal, | ||
) -> Result<CommandOutcome<String>, ComputationError> { | ||
Err(ComputationError::OperationNotSupported("NYI".into())) | ||
// use parsers::someip::{read_someip_statistic_from_pcapng, SomeipStatistic}; | ||
// use log::{error, warn}; | ||
// use std::path::Path; | ||
|
||
// let mut statistic = SomeipStatistic::new(); | ||
// let mut error: Option<String> = None; | ||
// warn!("Getting statistic for: {files:?}"); | ||
// files.iter().for_each(|file| { | ||
// if error.is_some() { | ||
// return; | ||
// } | ||
// if signal.is_cancelling() { | ||
// return; | ||
// } | ||
// match read_someip_statistic_from_pcapng(Path::new(&file), &signal.token()) { | ||
// Ok(result) => { | ||
// statistic.merge(result); | ||
// } | ||
// Err(err) => { | ||
// error = Some(err.to_string()); | ||
// } | ||
// } | ||
// }); | ||
// if let Some(err) = error { | ||
// error!("Fail to get statistic for: {files:?}"); | ||
// return Err(ComputationError::IoOperation(err)); | ||
// } | ||
// if signal.is_cancelling() { | ||
// warn!("Operation of geting statistic for: {files:?} has been cancelled"); | ||
// return Ok(CommandOutcome::Cancelled); | ||
// } | ||
// Ok(CommandOutcome::Finished( | ||
// serde_json::to_string(&statistic) | ||
// .map_err(|e| ComputationError::IoOperation(e.to_string()))?, | ||
// )) | ||
let mut statistic = SomeipStatistic::new(); | ||
let mut error: Option<String> = None; | ||
files.iter().for_each(|file| { | ||
if error.is_some() { | ||
return; | ||
} | ||
if signal.is_cancelling() { | ||
return; | ||
} | ||
match read_someip_statistic_from_pcapng(Path::new(&file), &signal.token()) { | ||
Ok(result) => { | ||
statistic.merge(result); | ||
} | ||
Err(err) => { | ||
error = Some(err.to_string()); | ||
} | ||
} | ||
}); | ||
if let Some(err) = error { | ||
return Err(ComputationError::IoOperation(err)); | ||
} | ||
if signal.is_cancelling() { | ||
return Ok(CommandOutcome::Cancelled); | ||
} | ||
Ok(CommandOutcome::Finished( | ||
serde_json::to_string(&statistic) | ||
.map_err(|e| ComputationError::IoOperation(e.to_string()))?, | ||
)) | ||
} |
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters