Pre-validate a proposed change against the leader's current state. This is called on the Control Plane before submitting to Raft. It uses the same validator but doesn't touch the DLQ — that's only for actual commit-time rejections.
(
validator: &Validator,
state: &CrdtState,
change: &ProposedChange,
)
| 32 | /// It uses the same validator but doesn't touch the DLQ — that's only |
| 33 | /// for actual commit-time rejections. |
| 34 | pub fn pre_validate( |
| 35 | validator: &Validator, |
| 36 | state: &CrdtState, |
| 37 | change: &ProposedChange, |
| 38 | ) -> PreValidationResult { |
| 39 | match validator.validate(state, change) { |
| 40 | ValidationOutcome::Accepted => PreValidationResult::Proceed, |
| 41 | ValidationOutcome::Rejected(violations) => { |
| 42 | let v = &violations[0]; |
| 43 | PreValidationResult::FastReject { |
| 44 | constraint: v.constraint_name.clone(), |
| 45 | reason: v.reason.clone(), |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | #[cfg(test)] |
| 52 | mod tests { |