Skip to content

Commit

Permalink
Nuke Job::failure_message
Browse files Browse the repository at this point in the history
  • Loading branch information
rustworthy committed Dec 30, 2024
1 parent 5cb4bd3 commit f1d4ea3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Support Faktory's `MUTATE` API ([#87])
- Make `Failure` struct public ([#89])
- `Job::failure_message` convenience method ([#89])

### Changed

Expand Down
11 changes: 0 additions & 11 deletions src/proto/single/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,17 +291,6 @@ impl Job {
pub fn failure(&self) -> Option<&Failure> {
self.failure.as_ref()
}

/// Error message for this job, if any.
///
/// A convenience method that, internally, will check if this
/// job has got a [`Failure`] and - if it does - will access
/// the failure's message (see [`Failure::message`]).
///
/// To access the entire failure, if any, use [`Job::failure`].
pub fn failure_message(&self) -> Option<&str> {
self.failure().as_ref().and_then(|f| f.message.as_deref())
}
}

pub async fn write_command<W: AsyncWrite + Unpin + Send, C: FaktoryCommand>(
Expand Down
9 changes: 4 additions & 5 deletions tests/real/community.rs
Original file line number Diff line number Diff line change
Expand Up @@ -964,10 +964,9 @@ async fn test_panic_and_errors_in_handler() {

// let's verify that errors messages in each job's `Failure` are as expected
for job in jobs {
assert_eq!(
job.failure_message().as_ref(),
job_kind_vs_error_msg.get(job.kind())
);
let error_message_got = job.failure().as_ref().unwrap().message.as_ref().unwrap();
let error_message_expected = *job_kind_vs_error_msg.get(job.kind()).unwrap();
assert_eq!(error_message_got, error_message_expected);
}
}

Expand Down Expand Up @@ -1050,7 +1049,7 @@ async fn mutation_requeue_jobs() {

assert_eq!(job.id(), &job_id); // sanity check

let failure_info = job.failure().as_ref().unwrap();
let failure_info = job.failure().unwrap();
assert_eq!(failure_info.retry_count, 0);
assert_eq!(
failure_info.retry_remaining,
Expand Down
2 changes: 2 additions & 0 deletions tests/real/utils.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use faktory::Job;

#[macro_export]
macro_rules! skip_check {
() => {
Expand Down

0 comments on commit f1d4ea3

Please sign in to comment.