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

Make background validation performed by Services configurable #2060 #2150

Conversation

brungardtdb
Copy link
Contributor

Added functionality to pass in a predefined validation configuration into Services so that it can be used in the Validation Service as outlined in #2060.

@brungardtdb brungardtdb force-pushed the brungardtdb/configure_background_validation branch from 4f8be06 to 288fb26 Compare December 23, 2023 16:37
@hannobraun
Copy link
Owner

Thank you for this pull request, @brungardtdb! I'm currently on vacation (for the rest of the year). I might take a look at this next week, when I get a chance, or at the latest in January, when I'm back to regular work.

…. Then passed the validation config into the validation service.
…d to the validation service, and added validate_with_config() method to object.rs
@brungardtdb brungardtdb force-pushed the brungardtdb/configure_background_validation branch from 288fb26 to c411a63 Compare January 1, 2024 18:11
Copy link
Owner

@hannobraun hannobraun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you again for the pull request, @brungardtdb! And I'm very sorry that it took me so long to review it. There was a confluence of factors that caused this. Usually, things around here work much more quickly!

I've left a few comments. Most are just me nit-picking, and fine to leave as-is (as noted in the respective comment). The only thing I'd like to see changed before merging, is the DerefMut implementation.

@@ -42,6 +42,18 @@ impl Services {
}
}

/// Construct an instance of `Services` with a pre-defined configuration for the validation service
pub fn with_validation_config(config: &ValidationConfig) -> Self {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems a bit misleading to take a &ValidationConfig that is then copied inside. It would be better to directly take ValidationConfig.

But this is not a blocker. Happy to merge as-is!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been addressed.

Comment on lines 15 to 16
/// Optional validation config
config: Option<ValidationConfig>,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably simpler to instead have config: ValidationConfig, and initialize that with its default value, if not provided.

But this would be a nice-to-have. Perfectly fine to merge this as-is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has also been addressed.

Comment on lines 65 to 69
impl<S: State> DerefMut for Service<S> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.state
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is used by the new Services constructor, which in itself seems fine. But this provides direct access to service state to all code, which seems error-prone.

I think there are two better ways to do this:

  1. Define a command for updating the validation config (see the existing ValidationCommand), make the execution of that command emit ValidationEvent::ConfigurationDefined, and use Service::execute to update the validation.
  2. In the new Services constructor, instead of using Service::<Validation>::default(), initialize the validation service with Service::new, which can be provided with a Validation that has the configuration set properly.

Solution 1 is more verbose, and probably more flexible than we need. So I'd prefer solution 2. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I agree with you, solution 1 seems like it might be overkill, so I will try my hand at solution 2 and see how that goes. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hannobraun , I believe I have managed to implement all of the changes that you had suggested. Please take a look and let me know if this is what you were going for! 😄

@brungardtdb
Copy link
Contributor Author

And I'm very sorry that it took me so long to review it. There was a confluence of factors that caused this. Usually, things around here work much more quickly!

No worries! I think I submitted this PR over the holidays, so I wasn't expecting to hear back right away. 😄

Passed in ValidationConfig directly instead of cloning a reference.
Removed optional ValidationConfig for ValidationService, use default or
config passed in through alternate constructor.
Deleted DerefMut implementation.
Copy link
Owner

@hannobraun hannobraun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, @brungardtdb! Thank you!

@hannobraun hannobraun merged commit 9d992aa into hannobraun:main Jan 14, 2024
4 checks passed
@brungardtdb brungardtdb deleted the brungardtdb/configure_background_validation branch January 14, 2024 19:41
@brungardtdb
Copy link
Contributor Author

@hannobraun, thank you!

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