diff --git a/cmd/immuadmin/command/database.go b/cmd/immuadmin/command/database.go index 9769c0fd01..8efd953084 100644 --- a/cmd/immuadmin/command/database.go +++ b/cmd/immuadmin/command/database.go @@ -38,14 +38,14 @@ func addDbUpdateFlags(c *cobra.Command) { c.Flags().Bool("replication-is-replica", false, "set database as a replica") c.Flags().Bool("replication-sync-enabled", false, "enable synchronous replication") c.Flags().Uint32("replication-sync-acks", 0, "set a minimum number of replica acknowledgements required before transactions can be committed") - c.Flags().String("replication-master-database", "", "set master database to be replicated") - c.Flags().String("replication-master-address", "", "set master address") - c.Flags().Uint32("replication-master-port", 0, "set master port") - c.Flags().String("replication-follower-username", "", "set username used for replication") - c.Flags().String("replication-follower-password", "", "set password used for replication") + c.Flags().String("replication-primary-database", "", "set primary database to be replicated") + c.Flags().String("replication-primary-host", "", "set primary database host") + c.Flags().Uint32("replication-primary-port", 0, "set primary database port") + c.Flags().String("replication-primary-username", "", "set username used for replication to connect to the primary database") + c.Flags().String("replication-primary-password", "", "set password used for replication to connect to the primary database") c.Flags().Uint32("replication-prefetch-tx-buffer-size", uint32(replication.DefaultPrefetchTxBufferSize), "maximum number of prefeched transactions") c.Flags().Uint32("replication-commit-concurrency", uint32(replication.DefaultReplicationCommitConcurrency), "number of concurrent replications") - c.Flags().Bool("replication-allow-tx-discarding", replication.DefaultAllowTxDiscarding, "allow precommitted transactions to be discarded if the follower diverges from the master") + c.Flags().Bool("replication-allow-tx-discarding", replication.DefaultAllowTxDiscarding, "allow precommitted transactions to be discarded if the replica diverges from the primary") c.Flags().Uint32("write-tx-header-version", 1, "set write tx header version (use 0 for compatibility with immudb 1.1, 1 for immudb 1.2+)") c.Flags().Uint32("max-commit-concurrency", store.DefaultMaxConcurrency, "set the maximum commit concurrency") c.Flags().Duration("sync-frequency", store.DefaultSyncFrequency, "set the fsync frequency during commit process") @@ -53,9 +53,18 @@ func addDbUpdateFlags(c *cobra.Command) { c.Flags().Uint32("read-tx-pool-size", database.DefaultReadTxPoolSize, "set transaction read pool size (used for reading transaction objects)") c.Flags().Bool("autoload", true, "enable database autoloading") + flagNameMapping := map[string]string{ + "replication-enabled": "replication-is-replica", + "replication-follower-username": "replication-primary-username", + "replication-follower-password": "replication-primary-password", + "replication-master-database": "replication-primary-database", + "replication-master-address": "replication-primary-host", + "replication-master-port": "replication-primary-port", + } + c.Flags().SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName { - if name == "replication-enabled" { - name = "replication-is-replica" + if newName, ok := flagNameMapping[name]; ok { + name = newName } return pflag.NormalizedName(name) }) @@ -390,27 +399,27 @@ func prepareDatabaseNullableSettings(flags *pflag.FlagSet) (*schema.DatabaseNull return nil, err } - ret.ReplicationSettings.MasterDatabase, err = condString("replication-master-database") + ret.ReplicationSettings.MasterDatabase, err = condString("replication-primary-database") if err != nil { return nil, err } - ret.ReplicationSettings.MasterAddress, err = condString("replication-master-address") + ret.ReplicationSettings.MasterAddress, err = condString("replication-primary-host") if err != nil { return nil, err } - ret.ReplicationSettings.MasterPort, err = condUInt32("replication-master-port") + ret.ReplicationSettings.MasterPort, err = condUInt32("replication-primary-port") if err != nil { return nil, err } - ret.ReplicationSettings.FollowerUsername, err = condString("replication-follower-username") + ret.ReplicationSettings.FollowerUsername, err = condString("replication-primary-username") if err != nil { return nil, err } - ret.ReplicationSettings.FollowerPassword, err = condString("replication-follower-password") + ret.ReplicationSettings.FollowerPassword, err = condString("replication-primary-password") if err != nil { return nil, err } diff --git a/cmd/immudb/command/init.go b/cmd/immudb/command/init.go index c8fb3a404f..1cd734a95d 100644 --- a/cmd/immudb/command/init.go +++ b/cmd/immudb/command/init.go @@ -36,13 +36,13 @@ func (cl *Commandline) setupFlags(cmd *cobra.Command, options *server.Options) { cmd.Flags().Bool("replication-is-replica", false, "set systemdb and defaultdb as replica") cmd.Flags().Bool("replication-sync-enabled", false, "enable synchronous replication") cmd.Flags().Int("replication-sync-acks", 0, "set a minimum number of replica acknowledgements required before transactions can be committed") - cmd.Flags().String("replication-master-address", "", "master address (if replica=true)") - cmd.Flags().Int("replication-master-port", 3322, "master port (if replica=true)") - cmd.Flags().String("replication-follower-username", "", "username used for replication of systemdb and defaultdb") - cmd.Flags().String("replication-follower-password", "", "password used for replication of systemdb and defaultdb") + cmd.Flags().String("replication-primary-host", "", "primary database host (if replica=true)") + cmd.Flags().Int("replication-primary-port", 3322, "primary database port (if replica=true)") + cmd.Flags().String("replication-primary-username", "", "username in the primary database used for replication of systemdb and defaultdb") + cmd.Flags().String("replication-primary-password", "", "password in the primary database used for replication of systemdb and defaultdb") cmd.Flags().Int("replication-prefetch-tx-buffer-size", options.ReplicationOptions.PrefetchTxBufferSize, "maximum number of prefeched transactions") cmd.Flags().Int("replication-commit-concurrency", options.ReplicationOptions.ReplicationCommitConcurrency, "number of concurrent replications") - cmd.Flags().Bool("replication-allow-tx-discarding", replication.DefaultAllowTxDiscarding, "allow precommitted transactions to be discarded if the follower diverges from the master") + cmd.Flags().Bool("replication-allow-tx-discarding", replication.DefaultAllowTxDiscarding, "allow precommitted transactions to be discarded if the replica diverges from the primary") cmd.PersistentFlags().StringVar(&cl.config.CfgFn, "config", "", "config file (default path are configs or $HOME. Default filename is immudb.toml)") cmd.Flags().String("pidfile", options.Pidfile, "pid path with filename e.g. /var/run/immudb.pid") @@ -84,9 +84,18 @@ func (cl *Commandline) setupFlags(cmd *cobra.Command, options *server.Options) { cmd.Flags().Duration("sessions-guard-check-interval", 1*time.Minute, "sessions guard check interval") cmd.Flags().MarkHidden("sessions-guard-check-interval") + flagNameMapping := map[string]string{ + "replication-enabled": "replication-is-replica", + "replication-follower-username": "replication-primary-username", + "replication-follower-password": "replication-primary-password", + "replication-master-database": "replication-primary-database", + "replication-master-address": "replication-primary-host", + "replication-master-port": "replication-primary-port", + } + cmd.Flags().SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName { - if name == "replication-enabled" { - name = "replication-is-replica" + if newName, ok := flagNameMapping[name]; ok { + name = newName } return pflag.NormalizedName(name) }) diff --git a/cmd/immudb/command/parse_options.go b/cmd/immudb/command/parse_options.go index 40fc9d56bc..58aa42fa66 100644 --- a/cmd/immudb/command/parse_options.go +++ b/cmd/immudb/command/parse_options.go @@ -36,10 +36,10 @@ func parseOptions() (options *server.Options, err error) { if replicationOptions.IsReplica { replicationOptions. - WithMasterAddress(viper.GetString("replication-master-address")). - WithMasterPort(viper.GetInt("replication-master-port")). - WithFollowerUsername(viper.GetString("replication-follower-username")). - WithFollowerPassword(viper.GetString("replication-follower-password")). + WithMasterAddress(viper.GetString("replication-primary-host")). + WithMasterPort(viper.GetInt("replication-primary-port")). + WithFollowerUsername(viper.GetString("replication-primary-username")). + WithFollowerPassword(viper.GetString("replication-primary-password")). WithPrefetchTxBufferSize(viper.GetInt("replication-prefetch-tx-buffer-size")). WithReplicationCommitConcurrency(viper.GetInt("replication-commit-concurrency")). WithAllowTxDiscarding(viper.GetBool("replication-allow-tx-discarding"))