-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: extract common arguments and fix clap arg clash
- Loading branch information
Showing
7 changed files
with
64 additions
and
103 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use crate::visitors::SendVisitor; | ||
use reqwest::Url; | ||
use walker_common::sender::{self, provider::OpenIdTokenProviderConfigArguments, HttpSender}; | ||
|
||
#[derive(Debug, clap::Parser)] | ||
#[command(next_help_heading = "Sending")] | ||
pub struct SendArguments { | ||
/// Target to send to | ||
pub target: Url, | ||
|
||
/// Sender connect timeout | ||
#[arg(id = "sender-connect-timeout", long, default_value = "15s")] | ||
pub connect_timeout: humantime::Duration, | ||
|
||
/// Sender request timeout | ||
#[arg(id = "sender-timeout", long, default_value = "5m")] | ||
pub timeout: humantime::Duration, | ||
|
||
/// Number of retries in case of temporary failures | ||
#[arg(id = "sender-retries", long, default_value = "0")] | ||
pub retries: usize, | ||
|
||
/// Delay between retries | ||
#[arg(id = "sender-retry-delay", long, default_value = "5s")] | ||
pub retry_delay: humantime::Duration, | ||
|
||
#[command(flatten)] | ||
pub oidc: OpenIdTokenProviderConfigArguments, | ||
} | ||
|
||
impl SendArguments { | ||
pub async fn into_visitor(self) -> Result<SendVisitor, anyhow::Error> { | ||
let provider = self.oidc.into_provider().await?; | ||
let sender = HttpSender::new( | ||
provider, | ||
sender::Options { | ||
connect_timeout: Some(self.connect_timeout.into()), | ||
timeout: Some(self.timeout.into()), | ||
}, | ||
) | ||
.await?; | ||
|
||
Ok(SendVisitor { | ||
url: self.target, | ||
sender, | ||
retries: self.retries, | ||
retry_delay: Some(self.retry_delay.into()), | ||
}) | ||
} | ||
} |
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
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