-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mutate API #87
base: main
Are you sure you want to change the base?
Mutate API #87
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't gotten all the way through this, but racked up a few comments so figured I'd leave them with you!
src/lib.rs
Outdated
pub use crate::proto::{ | ||
Client, Connection, DataSnapshot, FaktoryState, Job, JobBuilder, JobId, Reconnect, | ||
ServerSnapshot, WorkerId, | ||
Client, Connection, DataSnapshot, FaktoryState, Job, JobBuilder, JobId, MutationFilter, | ||
MutationFilterBuilder, MutationTarget, Reconnect, ServerSnapshot, WorkerId, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is starting to be a lot of top-level exports. How do you feel about starting to group some of them the way we've done with the pub mod ent
below? Like pub mod mutate
for example? Then we can also rename them to avoid the Mutation
name prefix.
Ok(w.write_all(b"INFO\r\n").await?) | ||
} | ||
} | ||
self_to_cmd!(Info); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I like the macro expansion here.
pub(crate) struct MutationAction<'a> { | ||
pub(crate) cmd: MutationType, | ||
pub(crate) target: MutationTarget, | ||
#[serde(skip_serializing_if = "filter_is_empty")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is an empty-but-set mutation filter actually == to an unset filter? In some systems, the two have different semantics (usually, unset means "use the default").
/// This method will immediately move the jobs from the targeted set (see [`MutationTarget`]) | ||
/// to their queues. This will apply to the jobs satisfying the [`filter`](crate::MutationFilter). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having a hard time following what this operation actually does. For example, with MutationTarget::Scheduled
, what does it mean for the jobs to "immediately be moved to their queues"? They're already in queues?
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)] | ||
#[serde(rename_all = "lowercase")] | ||
#[non_exhaustive] | ||
pub enum MutationTarget { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this actually specific to mutations? Feels like a general purpose job set specifier to me.
It's also weird to me that the "mutation target" isn't just another filter, given that seems to be the function it has.
/// client.requeue(MutationTarget::Retries, &filter).await.unwrap(); | ||
/// # }); | ||
/// ``` | ||
pub async fn requeue<'a, F>(&mut self, target: MutationTarget, filter: F) -> Result<(), Error> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The argument name target
makes me think that the jobs will be moved to this, but I don't think that's the case. Isn't it more like source
or candidate_job_set
or something?
pub kind: Option<&'a str>, | ||
|
||
/// Ids of jobs to target. | ||
#[serde(skip_serializing_if = "Option::is_none")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be send if empty?
/// As of Faktory version 1.9.2, if [`MutationFilter::pattern`] and/or [`MutationFilter::kind`] | ||
/// is specified, the values in [`MutationFilter::jids`] will not be taken into account by the | ||
/// server. If you want to filter by `jids`, make sure to leave other fields of the filter empty | ||
/// or use dedicated methods like [`Client::requeue_by_ids`]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that's the case, I wonder if we shouldn't derive builder and instead just have specific constructors (for now) for the combinations that do work. What do you think?
Co-authored-by: Jon Gjengset <jon@thesquareplanet.com>
Co-authored-by: Jon Gjengset <jon@thesquareplanet.com>
* Make Failure public * Update changelog * Get more info from panicking * Check different ways a job can fail * Add test clean up * Account for re-queued jobs * Check job id * Collect all kinds of handler failure * Add Job::failure_message. Check all error messages * Add to CHANGELOG.md. Fix clippy warning * Update tests/real/community.rs Co-authored-by: Jon Gjengset <jon@thesquareplanet.com> * Update src/proto/single/mod.rs Co-authored-by: Jon Gjengset <jon@thesquareplanet.com> * Fix docs to Failure * Nuke Job::failure_message * Nuke Job::failure_message * Restore comment in test_panic_and_errors_in_handler test * Add to the tests docs * Do not make Failure::kind pub --------- Co-authored-by: Jon Gjengset <jon@thesquareplanet.com>
addresses #61
this should also "unblock" #88
This change is