Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CLI flags -n, -t, T and -p #15

Merged
merged 36 commits into from
Mar 8, 2023
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
59ff20f
Bumped clap to v4
AntoniosBarotsis Feb 16, 2023
17749e0
Resolve build warning
AntoniosBarotsis Feb 17, 2023
75a5400
Moved some stuff to cargo.toml
AntoniosBarotsis Feb 17, 2023
c286692
Fix some clippy warnings
AntoniosBarotsis Feb 17, 2023
7eb9a97
fmt
AntoniosBarotsis Feb 17, 2023
f2e152f
Split to data.rs
AntoniosBarotsis Feb 17, 2023
ffd3181
Export url
AntoniosBarotsis Feb 17, 2023
84d8655
WIP
AntoniosBarotsis Feb 17, 2023
96b749d
Upgrade dependencies (cargo-audit/dependabot alerts)
AntoniosBarotsis Feb 17, 2023
188248d
Added a few TODOs
AntoniosBarotsis Feb 17, 2023
a17b488
Added more TODOs, max number of threads and some logs
AntoniosBarotsis Feb 17, 2023
4b2bd4a
Thread number error handling
AntoniosBarotsis Feb 17, 2023
071d04e
Don't spawn threads unless needed
AntoniosBarotsis Feb 17, 2023
f7af224
Remove outdated TODO
AntoniosBarotsis Feb 17, 2023
093aac4
Added logging
AntoniosBarotsis Feb 23, 2023
88148b5
Change default url to 8000 for now
AntoniosBarotsis Feb 23, 2023
e6c04f5
Simplify log
AntoniosBarotsis Feb 23, 2023
3e35f7c
Add flags (WIP)
AntoniosBarotsis Feb 26, 2023
36a3f48
Added TODO
AntoniosBarotsis Feb 26, 2023
5133de9
Cleanup builder
AntoniosBarotsis Feb 26, 2023
9e0bf59
Add clap's debug assert test
AntoniosBarotsis Feb 28, 2023
1e08e6a
Only use 1 http client per thread
AntoniosBarotsis Feb 28, 2023
34f9631
Take a reference to the client instead of ownership
AntoniosBarotsis Feb 28, 2023
fd31735
Remove loop param
AntoniosBarotsis Mar 1, 2023
d8f37da
Cleanup
AntoniosBarotsis Mar 1, 2023
95f283b
Added flag docs
AntoniosBarotsis Mar 1, 2023
d1e1f1a
Print errors.
AntoniosBarotsis Mar 1, 2023
450b7db
Resolve PR comments
AntoniosBarotsis Mar 4, 2023
b4241f6
Changed air purity messages
AntoniosBarotsis Mar 4, 2023
9807ab5
Resolve PR comments
AntoniosBarotsis Mar 5, 2023
5782646
Renamed `request` to `post`
AntoniosBarotsis Mar 5, 2023
863425f
Renamed response_format_str
AntoniosBarotsis Mar 5, 2023
1b8ed92
Fix tests
AntoniosBarotsis Mar 6, 2023
40be489
Added CI
AntoniosBarotsis Mar 6, 2023
e4fe9b1
Removed extra newline
AntoniosBarotsis Mar 6, 2023
f8510ad
Removed unused comment
AntoniosBarotsis Mar 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove loop param
AntoniosBarotsis committed Mar 1, 2023
commit fd317350d8dd254a51a90c610da252b6849b5976
3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -51,8 +51,6 @@ pub struct Cli {
pub total_time_s: Option<u64>,
#[arg(short = 'p', long)]
pub num_threads: Option<u32>,
#[arg(short = 'l', long, action)]
pub loop_indefinitely: bool,
}

pub fn run(cli: &Cli) -> Result<(), RequestSchedulerError> {
@@ -63,7 +61,6 @@ pub fn run(cli: &Cli) -> Result<(), RequestSchedulerError> {
.with_some_time_per_request(&cli.time_per_request_s.map(Duration::from_secs))
.with_some_total_time(&cli.total_time_s.map(Duration::from_secs))
.with_some_num_threads(&cli.num_threads)
.with_loop_indefinitely(cli.loop_indefinitely)
.build()?;

let dust_concentration = random_gen_dust_concentration();
16 changes: 2 additions & 14 deletions src/requests.rs
Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@ pub struct RequestSchedulerBuilder {
time_per_request: Option<Duration>,
total_time: Option<Duration>,
num_threads: Option<u32>,
loop_indefinitely: Option<bool>,
}

impl RequestSchedulerBuilder {
@@ -32,7 +31,6 @@ impl RequestSchedulerBuilder {
time_per_request: None,
total_time: None,
num_threads: None,
loop_indefinitely: None,
}
}

@@ -76,19 +74,9 @@ impl RequestSchedulerBuilder {
self
}

pub fn with_loop_indefinitely(mut self, loop_indefinitely: bool) -> Self {
self.loop_indefinitely = Some(loop_indefinitely);
self
}

pub fn with_some_loop_indefinitely(mut self, loop_indefinitely: &Option<bool>) -> Self {
self.loop_indefinitely = *loop_indefinitely;
self
}

pub fn build(self) -> Result<RequestScheduler, RequestSchedulerError> {
// Determine to loop indefinitely
let loop_indefinitely = self.loop_indefinitely.unwrap_or(false);
// Loop indefinitely if no req amt is set. If time per req is also not set then don't loop.
let loop_indefinitely = self.request_amount.is_none() && self.time_per_request.is_some();

let request_amount = self.request_amount.unwrap_or(DEFAULT_REQUEST_AMOUNT);