Skip to content
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

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open

Mutate API #87

wants to merge 23 commits into from

Conversation

rustworthy
Copy link
Collaborator

@rustworthy rustworthy commented Nov 19, 2024

addresses #61

this should also "unblock" #88


This change is Reviewable

Copy link

codecov bot commented Nov 20, 2024

Codecov Report

Attention: Patch coverage is 75.19380% with 32 lines in your changes missing coverage. Please review.

Project coverage is 67.7%. Comparing base (6ff7d60) to head (206e5f7).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
src/proto/client/mutation.rs 55.3% 29 Missing ⚠️
src/worker/mod.rs 81.8% 2 Missing ⚠️
src/proto/single/cmd.rs 96.6% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/proto/client/mod.rs 90.0% <ø> (+2.9%) ⬆️
src/proto/mod.rs 72.7% <ø> (ø)
src/proto/single/mod.rs 99.2% <100.0%> (+5.0%) ⬆️
src/proto/single/mutation.rs 100.0% <100.0%> (ø)
src/proto/single/cmd.rs 96.8% <96.6%> (-0.7%) ⬇️
src/worker/mod.rs 84.0% <81.8%> (-1.1%) ⬇️
src/proto/client/mutation.rs 55.3% <55.3%> (ø)

... and 1 file with indirect coverage changes

@rustworthy rustworthy changed the title [WIP] Mutate API Mutate API Nov 23, 2024
@rustworthy rustworthy requested a review from jonhoo November 23, 2024 09:19
Copy link
Owner

@jonhoo jonhoo left a 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
Comment on lines 108 to 111
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,
};
Copy link
Owner

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);
Copy link
Owner

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")]
Copy link
Owner

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").

Comment on lines +13 to +14
/// 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).
Copy link
Owner

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 {
Copy link
Owner

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>
Copy link
Owner

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?

src/proto/single/mutation.rs Outdated Show resolved Hide resolved
pub kind: Option<&'a str>,

/// Ids of jobs to target.
#[serde(skip_serializing_if = "Option::is_none")]
Copy link
Owner

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?

src/proto/client/mutation.rs Outdated Show resolved Hide resolved
Comment on lines +30 to +33
/// 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`].
Copy link
Owner

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?

rustworthy and others added 3 commits December 31, 2024 15:01
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants