Skip to content

Commit

Permalink
fix format & bug
Browse files Browse the repository at this point in the history
  • Loading branch information
smx-Morgan committed Oct 19, 2024
1 parent 86b6dda commit b991252
Show file tree
Hide file tree
Showing 10 changed files with 3 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ jobs:
with:
version: latest
working-directory: ${{ matrix.workdir }}
args: -E gofumpt --timeout 10m
args: -E gofumpt --out-format=colored-line-number --timeout 10m
skip-pkg-cache: true
2 changes: 1 addition & 1 deletion etcd/etcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func TestEtcdRegistryWithHertz(t *testing.T) {
resolver, _ := NewEtcdResolver([]string{"127.0.0.1:2379"})
newClient.Use(sd.Discovery(resolver))

addr := fmt.Sprintf("http://" + srvName + "/ping")
addr := fmt.Sprintf("http://%s/ping", srvName)
status, body, err := newClient.Get(context.Background(), nil, addr, config.WithSD(true))
assert.Nil(t, err)
assert.Equal(t, 200, status)
Expand Down
43 changes: 0 additions & 43 deletions etcd/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,11 @@
package etcd

import (
"crypto/tls"
"crypto/x509"
"errors"
"io/ioutil"
"time"

"github.com/cloudwego-contrib/cwgo-pkg/registry/etcd/etcdhertz"
)

const (
defaultTTL = 60
)

type option struct {
// etcd client config
options []etcdhertz.Option
}

/*type retryCfg struct {
// The maximum number of call attempt times, including the initial call
maxAttemptTimes uint
// observeDelay is the delay time for checking the service status under normal conditions
observeDelay time.Duration
// retryDelay is the delay time for attempting to register the service after disconnecting
retryDelay time.Duration
}*/

type Option = etcdhertz.Option

// WithMaxAttemptTimes sets the maximum number of call attempt times, including the initial call
Expand Down Expand Up @@ -85,24 +63,3 @@ func WithTLSOpt(certFile, keyFile, caFile string) Option {
func WithAuthOpt(username, password string) Option {
return etcdhertz.WithAuthOpt(username, password)
}

func newTLSConfig(certFile, keyFile, caFile, serverName string) (*tls.Config, error) {
cert, err := tls.LoadX509KeyPair(certFile, keyFile)
if err != nil {
return nil, err
}
caCert, err := ioutil.ReadFile(caFile)
if err != nil {
return nil, err
}
caCertPool := x509.NewCertPool()
successful := caCertPool.AppendCertsFromPEM(caCert)
if !successful {
return nil, errors.New("failed to parse ca certificate as PEM encoded content")
}
cfg := &tls.Config{
Certificates: []tls.Certificate{cert},
RootCAs: caCertPool,
}
return cfg, nil
}
1 change: 0 additions & 1 deletion etcd/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ const (
// NewEtcdRegistry creates a etcd based registry.
func NewEtcdRegistry(endpoints []string, opts ...Option) (registry.Registry, error) {
return etcdhertz.NewEtcdRegistry(endpoints, opts...)

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package main

import (
"context"

"sync"

"github.com/cloudwego/hertz/pkg/app"
Expand Down
31 changes: 0 additions & 31 deletions nacos/v2/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ import (
"strconv"

"github.com/cloudwego/hertz/pkg/common/hlog"
"github.com/nacos-group/nacos-sdk-go/v2/clients"
"github.com/nacos-group/nacos-sdk-go/v2/clients/naming_client"
"github.com/nacos-group/nacos-sdk-go/v2/common/constant"
"github.com/nacos-group/nacos-sdk-go/v2/vo"
)

const (
Expand All @@ -34,33 +30,6 @@ const (
nacosDefaultRegionID = "cn-hangzhou"
)

// newDefaultNacosConfig create a default Nacos client.
func newDefaultNacosConfig() (naming_client.INamingClient, error) {
sc := []constant.ServerConfig{
*constant.NewServerConfig(
GetAddr(),
uint64(GetPort()),
constant.WithContextPath("/nacos"),
constant.WithScheme("http"),
),
}
cc := constant.ClientConfig{
NamespaceId: GetNameSpaceID(),
RegionId: nacosDefaultRegionID,
NotLoadCacheAtStart: true,
}
client, err := clients.NewNamingClient(
vo.NacosClientParam{
ClientConfig: &cc,
ServerConfigs: sc,
},
)
if err != nil {
return nil, err
}
return client, nil
}

// GetPort Get Nacos port from environment variables.
func GetPort() int64 {
portText := os.Getenv(nacosEnvServerPort)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package main

import (
"context"

"sync"

"github.com/cloudwego/hertz/pkg/app"
Expand Down
1 change: 0 additions & 1 deletion nacos/v2/nacos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ func TestMultipleInstances(t *testing.T) {
Clusters: []string{clusterName},
HealthyOnly: true,
})

if err != nil {
assert.Equal(t, "instance list is empty!", err.Error())
}
Expand Down
5 changes: 0 additions & 5 deletions servicecomb/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ import (
"github.com/go-chassis/sc-client"
)

type resolverOptions struct {
options []options.ResolverOption
}

// ResolverOption is service-comb resolver option.
type ResolverOption = options.ResolverOption

Expand All @@ -50,5 +46,4 @@ func NewDefaultSCResolver(endPoints []string, opts ...ResolverOption) (discovery

func NewSCResolver(cli *sc.Client, opts ...ResolverOption) discovery.Resolver {
return servicecombhertz.NewSCResolver(cli, opts...)

}
2 changes: 1 addition & 1 deletion zookeeper/zookeeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestZookeeperRegistryWithHertz(t *testing.T) {
resolver, _ := NewZookeeperResolver([]string{"127.0.0.1:2181"}, 40*time.Second)
newClient.Use(sd.Discovery(resolver))

addr := fmt.Sprintf("http://" + srvName + "/ping")
addr := fmt.Sprintf("http://%s/ping", srvName)
status, body, err := newClient.Get(context.Background(), nil, addr, config.WithSD(true))
assert.Nil(t, err)
assert.Equal(t, 200, status)
Expand Down

0 comments on commit b991252

Please sign in to comment.