3 Commits

Author SHA1 Message Date
9c39c0daa2 chore(release): v0.3.3 (#22)
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
chore(release): 0.3.3

Co-authored-by: cuddle-please <bot@cuddle.sh>
Reviewed-on: https://git.front.kjuulh.io/kjuulh/drift/pulls/22
2025-03-27 14:11:17 +01:00
ca233208e2 feat: don't stop on error
All checks were successful
continuous-integration/drone/push Build is passing
2025-03-27 14:10:11 +01:00
3c9d15779d feat: redo main part
All checks were successful
continuous-integration/drone/push Build is passing
2025-03-27 14:08:26 +01:00
4 changed files with 27 additions and 20 deletions

View File

@@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [0.3.3] - 2025-03-27
### Added
- don't stop on error
- redo main part
## [0.3.2] - 2025-03-27 ## [0.3.2] - 2025-03-27
### Fixed ### Fixed

2
Cargo.lock generated
View File

@@ -249,7 +249,7 @@ dependencies = [
[[package]] [[package]]
name = "nodrift" name = "nodrift"
version = "0.3.1" version = "0.3.2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",

View File

@@ -3,7 +3,7 @@ members = ["crates/*"]
resolver = "2" resolver = "2"
[workspace.package] [workspace.package]
version = "0.3.2" version = "0.3.3"
[workspace.dependencies] [workspace.dependencies]
drift = { path = "crates/drift" } drift = { path = "crates/drift" }

View File

@@ -35,22 +35,7 @@ where
let drifter = drifter.clone(); let drifter = drifter.clone();
async move { async move {
let start = std::time::Instant::now(); let mut wait = Duration::default();
tracing::debug!("running job");
let child_token = cancellation_token.child_token();
if let Err(e) = drifter.execute(child_token).await {
tracing::error!("drift job failed with error: {}, stopping routine", e);
cancellation_token.cancel();
}
let elapsed = start.elapsed();
let mut wait = interval.saturating_sub(elapsed);
tracing::debug!(
"job took: {}ms, waiting: {}ms for next run",
elapsed.as_millis(),
wait.as_millis()
);
loop { loop {
let child_token = cancellation_token.child_token(); let child_token = cancellation_token.child_token();
@@ -68,8 +53,7 @@ where
tracing::debug!("running job"); tracing::debug!("running job");
if let Err(e) = drifter.execute(child_token).await { if let Err(e) = drifter.execute(child_token).await {
tracing::error!("drift job failed with error: {}, stopping routine", e); tracing::error!("drift job failed with error: {}", e);
cancellation_token.cancel();
continue continue
} }
@@ -228,6 +212,23 @@ mod tests {
assert!(logs_contain("running job")); assert!(logs_contain("running job"));
assert!(logs_contain("job took:")); assert!(logs_contain("job took:"));
Ok(())
}
#[tokio::test]
#[traced_test]
async fn test_calls_trace_on_start_and_end_long() -> anyhow::Result<()> {
let token = schedule(Duration::from_millis(100), || async {
tokio::time::sleep(std::time::Duration::from_millis(50)).await;
Ok(())
});
tokio::time::sleep(Duration::from_millis(500)).await;
assert!(!token.is_cancelled());
assert!(logs_contain("running job"));
assert!(logs_contain("job took:"));
Ok(()) Ok(())
} }
} }