Skip to content

Commit

Permalink
feat: address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 committed Dec 26, 2024
1 parent 4d5f6e1 commit 34e753c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions go/vt/vtgate/staticconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 12 additions & 4 deletions go/vt/vtgate/viperconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

0 comments on commit 34e753c

Please sign in to comment.