Skip to content

Commit

Permalink
Disallow Worker::run_one on a terminated worker
Browse files Browse the repository at this point in the history
  • Loading branch information
rustworthy committed Jul 21, 2024
1 parent 4c4dd58 commit 4415e60
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/worker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,20 @@ impl<S: AsyncBufRead + AsyncWrite + Send + Unpin, E: StdError + 'static + Send>
}

/// Fetch and run a single job, and then return.
///
/// Note that if you called [`Worker::run`] on this worker previously and the run
/// discontinued due to a signal from the Faktory server or a graceful shutdown signal,
/// calling this method will mean you are trying to run a _terminated_ worker which will
/// cause a panic. You will need to build and run a new worker instead.
pub async fn run_one<Q>(&mut self, worker: usize, queues: &[Q]) -> Result<bool, Error>
where
Q: AsRef<str> + Sync,
{
assert!(
!self.terminated,
"do not re-run a terminated worker (coordinator)"

Check warning on line 303 in src/worker/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/worker/mod.rs#L303

Added line #L303 was not covered by tests
);

let job = match self.c.fetch(queues).await? {
None => return Ok(false),
Some(j) => j,
Expand Down

0 comments on commit 4415e60

Please sign in to comment.