Skip to content

Commit

Permalink
Fixes #1 by running the API watcher in a loop inside the task
Browse files Browse the repository at this point in the history
  • Loading branch information
CmdrSharp committed Jun 8, 2023
1 parent 3b97344 commit 2d2685f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,18 @@ pub async fn watch() {
}

// Start the watcher
tokio::spawn({
let api: Api<Request> = api.clone();

async move {
tokio::spawn(async move {
loop {
let api: Api<Request> = api.clone();
_watch(api).await;
}
});
}

/// Start the watcher for CRD Creation/Deletion
async fn _watch(api: Api<Request>) {
tracing::info!("Watching for CRD Creation/Deletion");

if let Err(e) = watcher(api.clone(), watcher::Config::default())
.try_for_each(|r| {
tracing::debug!("Event: {:?}", r);
Expand Down

0 comments on commit 2d2685f

Please sign in to comment.