From 34e753ce749c96720053202973f71c38713a5914 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Thu, 26 Dec 2024 07:56:52 +0530 Subject: [PATCH] feat: address review comments Signed-off-by: Manan Gupta --- go/vt/vtgate/staticconfig.go | 3 +++ go/vt/vtgate/viperconfig.go | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/go/vt/vtgate/staticconfig.go b/go/vt/vtgate/staticconfig.go index 91ea20a2f36..f78545ebc5b 100644 --- a/go/vt/vtgate/staticconfig.go +++ b/go/vt/vtgate/staticconfig.go @@ -18,6 +18,9 @@ package vtgate import vtgatepb "vitess.io/vitess/go/vt/proto/vtgate" +// StaticConfig is a static configuration for vtgate. +// It is used for tests and vtexplain_vtgate where we don't want the user to +// control certain configs. type StaticConfig struct { OnlineDDLEnabled bool DirectDDLEnabled bool diff --git a/go/vt/vtgate/viperconfig.go b/go/vt/vtgate/viperconfig.go index c306a839be8..68430b7be2c 100644 --- a/go/vt/vtgate/viperconfig.go +++ b/go/vt/vtgate/viperconfig.go @@ -17,26 +17,34 @@ limitations under the License. package vtgate import ( + "vitess.io/vitess/go/viperutil" vtgatepb "vitess.io/vitess/go/vt/proto/vtgate" ) // DynamicViperConfig is a dynamic config that uses viper. type DynamicViperConfig struct { + onlineDDL viperutil.Value[bool] + directDDL viperutil.Value[bool] + txMode viperutil.Value[vtgatepb.TransactionMode] } // NewDynamicViperConfig creates a new dynamic viper config func NewDynamicViperConfig() *DynamicViperConfig { - return &DynamicViperConfig{} + return &DynamicViperConfig{ + onlineDDL: enableOnlineDDL, + directDDL: enableDirectDDL, + txMode: transactionMode, + } } func (d *DynamicViperConfig) OnlineEnabled() bool { - return enableOnlineDDL.Get() + return d.onlineDDL.Get() } func (d *DynamicViperConfig) DirectEnabled() bool { - return enableDirectDDL.Get() + return d.directDDL.Get() } func (d *DynamicViperConfig) TransactionMode() vtgatepb.TransactionMode { - return transactionMode.Get() + return d.txMode.Get() }