Skip to content

Conversation

@mandesero
Copy link

This patch adds the ability to keep and adjust the cluster declarative configuration with cluster:modify_config(), and then apply the changes later via cluster: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)
  • or other ad-hoc workarounds.

Usage example

local c = cluster:new(config, opts)
c:start()
-- <..do workload..>

c:modify_config()
    :set_global_option('replication.failover', 'manual')
c:apply_config_changes(<..maybe-opts..>)

-- <..do workload..>

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 via apply_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

This patch adds ability to keep and adjust cluster declarative
configuration with `cluster:modify_config()` and apply it later
via `сluster:apply_config_changes()` without passing an explicit
config.

Closes tarantool#426
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.

cluster: provide cbuilder config modifying API right inside cluster

1 participant