khepri_machine: Add API to wait for a behaviour to be effective#374
Draft
khepri_machine: Add API to wait for a behaviour to be effective#374
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #374 +/- ##
==========================================
- Coverage 89.97% 89.77% -0.20%
==========================================
Files 22 22
Lines 3531 3560 +29
==========================================
+ Hits 3177 3196 +19
- Misses 354 364 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
[Why] It is responsible for the mapping from an API behaviour to the state machine version the API behaviour was introduced in. We will be able to use it in a future API. The `does_api_comply_with/2` function is simplified by using `api_behaviour_to_machine_version/1`.
[Why] It allows to wait that a Khepri store runs the given machine version or more.
[Why] It allows to wait that a Khepri store supports a specific behaviour.
7bef340 to
827cd68
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
In the client code of the Khepri state machine, we need to know what version of the state machine is currently effective in the cluster before we can send some new commands. This is to avoid sending a new command to a member of the cluster that runs an older version of Khepri, causing it to possibly crash.
So far, we always had a fallback code path: if the new behaviour is not supported by the cluster, we could use an old way of doing somethin, or not doing it at all (keeping the old behaviour).
In a future patch, we will need to return an error to the caller to indicate the cluster is not ready for the behaviour it wants. Therefore, we need an API to allow the client code of the state machine (or the caller) to wait for a specific behaviour to be supported by the cluster.
How
The patch consists of three commits. The first one refactors the mapping between a given behaviour and the state machine version it wa introduced in.
The remaining two commits add functions to wait for the cluster to run a minimum version or a support a specific behaviour:
khepri_machine:wait_for_effective_machine_version/2khepri_machine:wait_for_effective_behaviour/2; this relies on the refactored behaviour/version mapping and thewait_for_effective_machine_version/2