Skip to content

Commit

Permalink
remove tso server initialization path from main() for now.
Browse files Browse the repository at this point in the history
Will integrate with @lhy1024's subcommand change later

Handle feedback

Signed-off-by: Bin Shi <binshi.bing@gmail.com>
  • Loading branch information
binshi-bing committed Feb 8, 2023
1 parent 661b22d commit 68f317a
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 40 deletions.
17 changes: 1 addition & 16 deletions cmd/pd-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"flag"
"os"
"os/signal"
"strings"
"syscall"

grpcprometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
Expand All @@ -29,7 +28,6 @@ import (
basicsvr "github.com/tikv/pd/pkg/basic_server"
"github.com/tikv/pd/pkg/dashboard"
"github.com/tikv/pd/pkg/errs"
tsoserver "github.com/tikv/pd/pkg/mcs/tso/server"
"github.com/tikv/pd/pkg/swaggerserver"
"github.com/tikv/pd/pkg/utils/logutil"
"github.com/tikv/pd/pkg/utils/metricutil"
Expand All @@ -48,20 +46,7 @@ import (
)

func main() {
var ctx context.Context
var cancel context.CancelFunc
var svr basicsvr.Server

if len(os.Args) < 2 {
ctx, cancel, svr = createServerWrapper(os.Args[1:])
} else {
switch strings.ToLower(os.Args[1]) {
case "service-mode-tso":
ctx, cancel, svr = tsoserver.CreateServerWrapper(os.Args[2:])
default:
ctx, cancel, svr = createServerWrapper(os.Args[2:])
}
}
ctx, cancel, svr := createServerWrapper(os.Args[1:])

sc := make(chan os.Signal, 1)
signal.Notify(sc,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ require (
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/petermattis/goid v0.0.0-20211229010228-4d14c490ee36 // indirect
github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e // indirect
github.com/pkg/errors v0.9.1
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 // indirect
github.com/prometheus/procfs v0.0.3 // indirect
Expand Down
2 changes: 1 addition & 1 deletion pkg/basic_server/basic_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ type Server interface {

// GetClient returns builtin etcd client.
GetClient() *clientv3.Client
// GetHTTPClient returns builtin etcd client.
// GetHTTPClient returns builtin http client.
GetHTTPClient() *http.Client
}
21 changes: 7 additions & 14 deletions pkg/mcs/tso/server/server.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016 TiKV Project Authors.
// Copyright 2023 TiKV Project Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,7 +31,7 @@ import (
"go.etcd.io/etcd/clientv3"
)

// if server doesn't implement all methods of basicsvr.Server, this line will result in a clear
// If server doesn't implement all methods of basicsvr.Server, this line will result in a clear
// error message like "*Server does not implement basicsvr.Server (missing Method method)"
var _ basicsvr.Server = (*Server)(nil)

Expand All @@ -41,7 +41,7 @@ type Server struct {
ctx context.Context
}

// TODO: Implement the following methos
// TODO: Implement the following methods defined in basicsvr.Server

// Name returns the unique etcd Name for this server in etcd cluster.
func (s *Server) Name() string {
Expand All @@ -62,17 +62,12 @@ func (s *Server) Run() error {
func (s *Server) Close() {
}

// IsClosed checks whether server is closed or not.
func (s *Server) IsClosed() bool {
return true
}

// GetClient returns builtin etcd client.
func (s *Server) GetClient() *clientv3.Client {
return nil
}

// GetHTTPClient returns builtin etcd client.
// GetHTTPClient returns builtin http client.
func (s *Server) GetHTTPClient() *http.Client {
return nil
}
Expand Down Expand Up @@ -109,18 +104,16 @@ func CreateServerWrapper(args []string) (context.Context, context.CancelFunc, ba

metricutil.Push(&cfg.Metric)

// Joins the cluster
// ...

// Creates the server
// ...
// TODO: Create the server

return nil, nil, nil
}

// TODO: implement it
func printVersionInfo() {
}

// TODO: implement it
func printConfigCheckMsg(cfg *tso.Config) {
}

Expand Down
8 changes: 2 additions & 6 deletions pkg/tso/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,14 @@ import (
"flag"
"time"

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

const (
defaultLeaderLease = int64(3)
defaultTSOSaveInterval = time.Duration(defaultLeaderLease) * time.Second
// DefaultTSOUpdatePhysicalInterval is the default value of the config `TSOUpdatePhysicalInterval`.
// defaultTSOUpdatePhysicalInterval is the default value of the config `TSOUpdatePhysicalInterval`.
defaultTSOUpdatePhysicalInterval = 50 * time.Millisecond
daxTSOUpdatePhysicalInterval = 10 * time.Second
dinTSOUpdatePhysicalInterval = 1 * time.Millisecond
)

// Config is the configuration for the TSO.
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/configutil/configutil.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 TiKV Project Authors.
// Copyright 2023 TiKV Project Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ func (s *Server) GetClient() *clientv3.Client {
return s.client
}

// GetHTTPClient returns builtin etcd client.
// GetHTTPClient returns builtin http client.
func (s *Server) GetHTTPClient() *http.Client {
return s.httpClient
}
Expand Down

0 comments on commit 68f317a

Please sign in to comment.