Browse Source

improve cli handling

main
Georg Hopp 11 months ago
parent
commit
9cb4ba6bf2
Signed by: ghopp GPG Key ID: 4C5D226768784538
  1. 43
      src/main.rs

43
src/main.rs

@ -25,15 +25,30 @@ struct Args {
name: PathBuf,
#[arg(short, long)]
url: String,
#[arg(short, long)]
buffer: Option<usize>,
#[arg(short, long)]
rate: Option<u64>,
#[arg(short, long)]
concurrency: Option<usize>,
#[arg(short, long)]
timeout: Option<u64>,
#[arg(short = 'B', default_value_t = false, help = "use body timeout")]
#[arg( short
, long
, default_value_t = 10
, help = "request to store in client after \
concurrency limit reached" )]
buffer: usize,
#[arg( short
, long
, default_value_t = 40
, help = "number of requests per second the client should perform" )]
rate: u64,
#[arg( short
, long
, default_value_t = 20
, help = "number of concurrent requests" )]
concurrency: usize,
#[arg( short
, long
, default_value_t = 30
, help = "network io timeout" )]
timeout: u64,
#[arg( short = 'B'
, default_value_t = false
, help = "also use timeout on body reads" )]
use_body_timeout: bool,
#[arg( short
, default_value_t = 301
@ -73,11 +88,7 @@ async fn main() -> anyhow::Result<()> {
Err(anyhow!("Only filenames with .mp4 extension are allowed"))?
}
let buffer = args.buffer.unwrap_or(20);
let rate_limit = args.rate.unwrap_or(20);
let concurrency_limit = args.concurrency.unwrap_or(20);
let timeout = args.timeout.unwrap_or(15);
let timeout = Duration::from_secs(timeout);
let timeout = Duration::from_secs(args.timeout);
let wait_time = Duration::from_secs(args.wait);
let body_timeout = if args.use_body_timeout {
Some(timeout)
@ -93,7 +104,7 @@ async fn main() -> anyhow::Result<()> {
info!("Creating an HTTP client with Tower layers...");
let client = Client::new(buffer, rate_limit, concurrency_limit, timeout)?
let client = Client::new(args.buffer, args.rate, args.concurrency, timeout)?
. set_body_timeout(body_timeout)
. set_origin(args.origin)?;
@ -103,7 +114,7 @@ async fn main() -> anyhow::Result<()> {
client
};
let actor = ClientActorHandle::new(client, buffer + concurrency_limit);
let actor = ClientActorHandle::new(client, args.buffer + args.concurrency);
info!("Get segments...");

Loading…
Cancel
Save