Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into main-github
Browse files Browse the repository at this point in the history
  • Loading branch information
Dot-Liu committed Jun 18, 2024
2 parents 899f64e + e8c1436 commit 69b0d46
Show file tree
Hide file tree
Showing 13 changed files with 156 additions and 138 deletions.
13 changes: 5 additions & 8 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func Example() {

func TestGetListens(t *testing.T) {
type args struct {
ucs []UrlConfig
ucs UrlConfig
}
tests := []struct {
name string
Expand All @@ -24,20 +24,17 @@ func TestGetListens(t *testing.T) {
{
name: "test",
args: args{
ucs: []UrlConfig{
{
ListenUrls: []string{"http://0.0.0.0:8088", "http://0.0.0.0", "https://0.0.0.0", "http://192.168.0.5", "https://192.168.0.5"},
Certificate: nil,
AdvertiseUrls: nil,
},
ucs: UrlConfig{

ListenUrl: ListenUrl{ListenUrls: []string{"http://0.0.0.0:8088", "http://0.0.0.0", "https://0.0.0.0", "http://192.168.0.5", "https://192.168.0.5"}},
},
},
want: []string{":8088", ":80", ":443", "192.168.0.5:80", "192.168.0.5:443"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
addrs := GetListens(tt.args.ucs...)
addrs := GetListens(tt.args.ucs.ListenUrl)
sort.Strings(addrs)
sort.Strings(tt.want)
assert.Equalf(t, tt.want, addrs, "GetListens(%v)", tt.name)
Expand Down
14 changes: 11 additions & 3 deletions debug/pprof.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"net/http/pprof"
)

var ()

func RunDebug(name string) {

addr, has := env.GetEnv(fmt.Sprintf("PPROF_%s", name))
Expand All @@ -30,7 +28,9 @@ func RunDebug(name string) {
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)

for path, handler := range appendHandler {
mux.HandleFunc(path, handler)
}
lAddr := listen.Addr().(*net.TCPAddr)

log.Infof("start pprof:\thttp%s:%d", lAddr.IP.String(), lAddr.Port)
Expand All @@ -46,3 +46,11 @@ func RunDebug(name string) {
}()

}

var (
appendHandler = map[string]func(w http.ResponseWriter, r *http.Request){}
)

func Register(s string, handler func(w http.ResponseWriter, r *http.Request)) {
appendHandler[s] = handler
}
4 changes: 2 additions & 2 deletions etcd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ func (s *_Server) etcdServerConfig() config.ServerConfig {
var urlsmap types.URLsMap
var token string
if !wal.Exist(filepath.Join(dataDir, "member", "wal")) {
urlsmap, _ = types.NewURLsMap(InitialCluster)

token = "APINTO_CLUSTER"
}

urlsmap, _ = types.NewURLsMap(InitialCluster)
srvCfg := config.ServerConfig{

ClientURLs: clientUrl,
Expand Down
8 changes: 4 additions & 4 deletions etcd/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
)

func (s *_Server) peerMembersHandler(w http.ResponseWriter, r *http.Request) {
s.mu.RLock()
defer s.mu.RUnlock()
//s.mu.RLock()
//defer s.mu.RUnlock()
if !allowMethod(w, r, "GET") {
return
}
Expand All @@ -37,8 +37,8 @@ func (s *_Server) peerMembersHandler(w http.ResponseWriter, r *http.Request) {
}

func (s *_Server) peerMemberPromoteHandler(w http.ResponseWriter, r *http.Request) {
s.mu.RLock()
defer s.mu.RUnlock()
//s.mu.RLock()
//defer s.mu.RUnlock()

if !allowMethod(w, r, "POST") {
return
Expand Down
4 changes: 2 additions & 2 deletions etcd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func (s *_Server) Nodes() []*Node {

func (s *_Server) Version() Versions {

s.mu.RLock()
defer s.mu.RUnlock()
//s.mu.RLock()
//defer s.mu.RUnlock()
strv := "not_decided"
if s.server != nil {
v := s.server.Cluster().Version()
Expand Down
51 changes: 28 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,37 @@ go 1.19
require (
github.com/dustin/go-humanize v1.0.0
github.com/ghodss/yaml v1.0.0
github.com/golang/protobuf v1.5.2
github.com/google/uuid v1.3.0
github.com/golang/protobuf v1.5.4
github.com/google/uuid v1.4.0
github.com/gorilla/websocket v1.4.2
github.com/jhump/protoreflect v1.14.1
github.com/jhump/protoreflect v1.16.0
github.com/julienschmidt/httprouter v1.3.0
github.com/soheilhy/cmux v0.1.5
github.com/stretchr/testify v1.8.1
github.com/stretchr/testify v1.8.4
github.com/urfave/cli/v2 v2.23.4
github.com/valyala/fasthttp v1.42.0
go.etcd.io/bbolt v1.3.7
go.etcd.io/etcd/api/v3 v3.5.7
go.etcd.io/etcd/client/pkg/v3 v3.5.7
go.etcd.io/etcd/client/v3 v3.5.7
go.etcd.io/etcd/server/v3 v3.5.7
go.etcd.io/bbolt v1.3.9
go.etcd.io/etcd/api/v3 v3.5.13
go.etcd.io/etcd/client/pkg/v3 v3.5.13
go.etcd.io/etcd/client/v3 v3.5.13
go.etcd.io/etcd/server/v3 v3.5.13
go.uber.org/zap v1.23.0
golang.org/x/crypto v0.1.0
golang.org/x/sys v0.4.0
google.golang.org/grpc v1.50.1
google.golang.org/protobuf v1.28.1
golang.org/x/crypto v0.21.0
golang.org/x/sys v0.18.0
google.golang.org/grpc v1.61.0
google.golang.org/protobuf v1.33.1-0.20240408130810-98873a205002
)

require (
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
github.com/google/btree v1.0.1 // indirect
Expand All @@ -54,18 +56,21 @@ require (
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
go.etcd.io/etcd/client/v2 v2.305.7 // indirect
go.etcd.io/etcd/pkg/v3 v3.5.7 //indirect
go.etcd.io/etcd/raft/v3 v3.5.7 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.25.0 // indirect
go.opentelemetry.io/otel v1.0.1 // indirect
go.opentelemetry.io/otel/trace v1.0.1 // indirect
go.etcd.io/etcd/client/v2 v2.305.13 // indirect
go.etcd.io/etcd/pkg/v3 v3.5.13 //indirect
go.etcd.io/etcd/raft/v3 v3.5.13 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.0 // indirect
go.opentelemetry.io/otel v1.20.0 // indirect
go.opentelemetry.io/otel/metric v1.20.0 // indirect
go.opentelemetry.io/otel/trace v1.20.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/text v0.6.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect
google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 69b0d46

Please sign in to comment.