Skip to content

Commit

Permalink
Fixed gofmt and typos found by make check.
Browse files Browse the repository at this point in the history
Signed-off-by: Bin Shi <binshi.bing@gmail.com>
  • Loading branch information
binshi-bing committed Feb 7, 2023
1 parent ae710d5 commit 0a22f7e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/pd-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
"github.com/pingcap/errors"
"github.com/pingcap/log"
"github.com/tikv/pd/pkg/autoscaling"
basicsvr "github.com/tikv/pd/pkg/basic_server"
"github.com/tikv/pd/pkg/dashboard"
"github.com/tikv/pd/pkg/errs"
basicsvr "github.com/tikv/pd/pkg/basic_server"
tsoserver "github.com/tikv/pd/pkg/mcs/tso/server"
"github.com/tikv/pd/pkg/swaggerserver"
"github.com/tikv/pd/pkg/utils/logutil"
Expand Down
1 change: 1 addition & 0 deletions pkg/basic_server/basic_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"go.etcd.io/etcd/clientv3"
)

// Server defines the common basic behaviors of a server
type Server interface {
// Name returns the unique etcd Name for this server in etcd cluster.
Name() string
Expand Down
10 changes: 2 additions & 8 deletions pkg/mcs/tso/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,20 @@ package server

import (
"flag"
"time"

"github.com/pkg/errors"
"github.com/tikv/pd/pkg/utils/metricutil"
"github.com/tikv/pd/pkg/utils/typeutil"
)

const (
// defaultTSOUpdatePhysicalInterval is the default value of the config `TSOUpdatePhysicalInterval`.
defaultTSOUpdatePhysicalInterval = 50 * time.Millisecond
)

// Config is the configuration for the TSO.
type Config struct {
flagSet *flag.FlagSet

Version bool `json:"-"`

ConfigCheck bool `json:"-"`
configFile string
configFile string

// EnableLocalTSO is used to enable the Local TSO Allocator feature,
// which allows the PD server to generate Local TSO for certain DC-level transactions.
Expand Down Expand Up @@ -81,4 +75,4 @@ func (c *Config) Parse(arguments []string) error {
// TODO: Implement the main function body

return nil
}
}
1 change: 1 addition & 0 deletions pkg/mcs/tso/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func (s *Server) GetHTTPClient() *http.Client {
return nil
}

// CreateServerWrapper encapsulates the configuration/log/metrics initialization and create the server
func CreateServerWrapper(args []string) (context.Context, context.CancelFunc, basicsvr.Server) {
cfg := NewConfig()
err := cfg.Parse(os.Args[1:])
Expand Down
1 change: 0 additions & 1 deletion pkg/tso/allocator_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ func CalSuffixBits(maxSuffix int32) int {
func (am *AllocatorManager) SetUpAllocator(parentCtx context.Context, dcLocation string, leadership *election.Leadership) {
am.mu.Lock()
defer am.mu.Unlock()

if _, exist := am.mu.allocatorGroups[dcLocation]; exist {
return
}
Expand Down
8 changes: 6 additions & 2 deletions pkg/utils/configutil/configutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@ import (
"github.com/BurntSushi/toml"
)

// Utility to test if a configuration is defined.
// ConfigMetaData is an utility to test if a configuration is defined.
type ConfigMetaData struct {
meta *toml.MetaData
path []string
}

// NewConfigMetadata is the a factory method to create a ConfigMetaData object
func NewConfigMetadata(meta *toml.MetaData) *ConfigMetaData {
return &ConfigMetaData{meta: meta}
}

// IsDefined checks if the given key is defined in the configuration
func (m *ConfigMetaData) IsDefined(key string) bool {
if m.meta == nil {
return false
Expand All @@ -39,6 +41,7 @@ func (m *ConfigMetaData) IsDefined(key string) bool {
return m.meta.IsDefined(keys...)
}

// Child gets the config metadata of the given path
func (m *ConfigMetaData) Child(path ...string) *ConfigMetaData {
newPath := append([]string(nil), m.path...)
newPath = append(newPath, path...)
Expand All @@ -48,6 +51,7 @@ func (m *ConfigMetaData) Child(path ...string) *ConfigMetaData {
}
}

// CheckUndecoded checks if the configuration contains undefined items
func (m *ConfigMetaData) CheckUndecoded() error {
if m.meta == nil {
return nil
Expand All @@ -61,4 +65,4 @@ func (m *ConfigMetaData) CheckUndecoded() error {
errInfo += key.String() + ", "
}
return errors.New(errInfo[:len(errInfo)-2])
}
}

0 comments on commit 0a22f7e

Please sign in to comment.