-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: deadline support and rm verbose (#6)
- support for timeout (deadline) using humantime expressions. e.g. `wait-on -t 10m ...` - removes log on failed http requests for simplicity (as redundant)
- Loading branch information
Showing
12 changed files
with
75 additions
and
20 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
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
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
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,29 @@ | ||
use anyhow::{bail, Result}; | ||
use tokio::select; | ||
use tokio::time::sleep; | ||
|
||
use crate::resource::Resource; | ||
use crate::{WaitOptions, Waitable}; | ||
|
||
pub struct WaitOnTask { | ||
resource: Resource, | ||
options: WaitOptions, | ||
} | ||
|
||
impl WaitOnTask { | ||
pub fn new(resource: Resource, options: WaitOptions) -> Self { | ||
Self { resource, options } | ||
} | ||
|
||
pub async fn run(self) -> Result<()> { | ||
select! { | ||
_ = self.resource.wait(&self.options) => Ok(()), | ||
_ = self.deadline() => bail!("Deadline reached"), | ||
} | ||
} | ||
|
||
async fn deadline(&self) -> Result<()> { | ||
sleep(self.options.timeout).await; | ||
bail!("Timeout reached"); | ||
} | ||
} |