cluster: add helpers to modify cluster config #434
+137
−1
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.
This patch adds the ability to keep and adjust the cluster declarative configuration with
cluster:modify_config(), and then apply the changes later viacluster:apply_config_changes()without passing an explicit config.Motivation
Instead of overloading
cluster:sync(...), I decided to introduce a dedicated method:apply_config_changes(). This avoids awkward patterns such as:cluster:sync(nil, opts)cluster:sync(cluster:modify_config():<some-conf>:config(), opts)Usage example
Backward compatibility
The old API continues to work.
However, to avoid ambiguous states when using the new API, the following rules now apply:
If
modify_config()has been used and the changes were not committed viaapply_config_changes(), calling:c:sync(new_config, opts),c:reload(new_config)will raise an exception.
New
c:config()returns the last applied configuration, so calling it while there is an uncommitted builder also raises an exception.This ensures the cluster object never ends up in a half-modified state.
That said, I’m open to discussion if this behavior doesn’t fully meet expectations for this feature.
Closes #426