Skip to content

Commit

Permalink
fix some problems
Browse files Browse the repository at this point in the history
  • Loading branch information
zhu-mi-shan committed Jun 19, 2024
1 parent f596224 commit 6ebc231
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 31 deletions.
2 changes: 1 addition & 1 deletion etcd/client/client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package etcdclient
package client

import (
clientv3 "go.etcd.io/etcd/client/v3"
Expand Down
2 changes: 1 addition & 1 deletion etcd/client/decoder.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package etcdclient
package client

import (
"encoding/json"
Expand Down
4 changes: 2 additions & 2 deletions etcd/client/loader.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package etcdclient
package client

import (
kitexclient "github.com/cloudwego/kitex/client"
Expand All @@ -9,7 +9,7 @@ type Translator func(config *EtcdConfig) ([]kitexclient.Option, error)

type Loader interface {
Load() error
GetSuite() EtcdClientSuite
GetSuite() *EtcdClientSuite
}

type EtcdLoader struct {
Expand Down
2 changes: 1 addition & 1 deletion etcd/client/reader.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package etcdclient
package client

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion etcd/client/suite.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package etcdclient
package client

import (
"github.com/cloudwego/kitex/client"
Expand Down
4 changes: 2 additions & 2 deletions etcd/client/translator.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package etcdclient
package client

import (
"fmt"
"github.com/Printemps417/optionloader/utils"
kitexclient "github.com/cloudwego/kitex/client"
"github.com/cloudwego/kitex/pkg/connpool"
"github.com/cloudwego/kitex/pkg/rpcinfo"
"github.com/cloudwego/kitex/transport"
"github.com/kitex-contrib/optionloader/utils"
)

// Protocol indicates the transport protocol.
Expand Down
4 changes: 2 additions & 2 deletions etcd/server/decoder.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package etcdserver
package server

import (
"encoding/json"
Expand Down Expand Up @@ -31,7 +31,7 @@ type EtcdConfig struct {
func (c *EtcdConfig) String() string {
var builder strings.Builder
if c.ServerBasicInfo != nil {
builder.WriteString(fmt.Sprintf("ClientBasicInfo: %v\n", *c.ServerBasicInfo))
builder.WriteString(fmt.Sprintf("ServerBasicInfo: %v\n", *c.ServerBasicInfo))
}
if c.ServiceAddr != nil {
builder.WriteString(fmt.Sprintf("ServiceAddr: %v\n", c.ServiceAddr))
Expand Down
4 changes: 2 additions & 2 deletions etcd/server/loader.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package etcdserver
package server

import (
"github.com/cloudwego/kitex/pkg/klog"
Expand All @@ -9,7 +9,7 @@ type Translator func(config *EtcdConfig) ([]kitexserver.Option, error)

type Loader interface {
Load() error
GetSuite() EtcdServerSuite
GetSuite() *EtcdServerSuite
}

type EtcdLoader struct {
Expand Down
10 changes: 5 additions & 5 deletions etcd/server/reader.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package etcdserver
package server

import (
"bytes"
Expand Down Expand Up @@ -26,8 +26,8 @@ type EtcdReader struct {
config *EtcdConfig //配置文件读出结果
parser ConfigParser //配置文件解码器
etcdClient *ecli.Client
clientPathTemplate *template.Template
clientPath string
serverPathTemplate *template.Template
serverPath string
prefix string
etcdTimeout time.Duration
}
Expand All @@ -42,11 +42,11 @@ func (r *EtcdReader) SetDecoder(decoder ConfigParser) error {
}
func (r *EtcdReader) ReadToConfig(p *Path) error {
var err error
r.clientPath, err = r.render(p, r.clientPathTemplate)
r.serverPath, err = r.render(p, r.serverPathTemplate)
if err != nil {
return err
}
key := r.prefix + r.clientPath
key := r.prefix + r.serverPath
ctx2, cancel := context.WithTimeout(context.Background(), r.etcdTimeout)
defer cancel()
data, err := r.etcdClient.Get(ctx2, key)
Expand Down
6 changes: 3 additions & 3 deletions etcd/server/server.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package etcdserver
package server

import (
clientv3 "go.etcd.io/etcd/client/v3"
Expand Down Expand Up @@ -39,7 +39,7 @@ func NewReader(opts ReaderOptions) (*EtcdReader, error) {
if err != nil {
return nil, err
}
clientPathTemplate, err := template.New("clientName").Parse(opts.PathFormat)
serverPathTemplate, err := template.New("serverName").Parse(opts.PathFormat)
if err != nil {
return nil, err
}
Expand All @@ -48,7 +48,7 @@ func NewReader(opts ReaderOptions) (*EtcdReader, error) {
parser: opts.ConfigParser, //配置文件解码器
etcdClient: etcdClient,
prefix: opts.Prefix,
clientPathTemplate: clientPathTemplate,
serverPathTemplate: serverPathTemplate,
etcdTimeout: opts.Timeout,
}

Expand Down
2 changes: 1 addition & 1 deletion etcd/server/suite.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package etcdserver
package server

import (
"github.com/cloudwego/kitex/server"
Expand Down
2 changes: 1 addition & 1 deletion etcd/server/translator.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package etcdserver
package server

import (
"errors"
Expand Down
4 changes: 2 additions & 2 deletions examples/etcd/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"encoding/json"
"fmt"
etcdClient "github.com/Printemps417/optionloader/etcd/client"
"github.com/Printemps417/optionloader/utils"
kitexclient "github.com/cloudwego/kitex/client"
etcdClient "github.com/kitex-contrib/optionloader/etcd/client"
"github.com/kitex-contrib/optionloader/utils"
examplegen "github.com/zhu-mi-shan/optionloader_example/kitex_gen/example"
example "github.com/zhu-mi-shan/optionloader_example/kitex_gen/example/testservice"
"log"
Expand Down
4 changes: 2 additions & 2 deletions examples/etcd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"encoding/json"
"fmt"
etcdServer "github.com/Printemps417/optionloader/etcd/server"
"github.com/Printemps417/optionloader/utils"
kitexserver "github.com/cloudwego/kitex/server"
etcdServer "github.com/kitex-contrib/optionloader/etcd/server"
"github.com/kitex-contrib/optionloader/utils"
examplegen "github.com/zhu-mi-shan/optionloader_example/kitex_gen/example"
example "github.com/zhu-mi-shan/optionloader_example/kitex_gen/example/testservice"
"log"
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/Printemps417/optionloader
module github.com/kitex-contrib/optionloader

go 1.22.1
go 1.20

require (
github.com/cloudwego/kitex v0.10.0
Expand Down
3 changes: 0 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20220608213341-c488b8fa1db3/go.mod h1:gSuNB+gJaOiQKLEZ+q+PK9Mq3SOzhRcw2GsGS/FhYDk=
github.com/google/pprof v0.0.0-20240618054019-d3b898a103f8 h1:ASJ/LAqdCHOyMYI+dwNxn7Rd8FscNkMyTr1KZU1JI/M=
Expand Down Expand Up @@ -151,7 +150,6 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down Expand Up @@ -215,7 +213,6 @@ go.etcd.io/etcd/client/pkg/v3 v3.5.14/go.mod h1:8uMgAokyG1czCtIdsq+AGyYQMvpIKnSv
go.etcd.io/etcd/client/v3 v3.5.14 h1:CWfRs4FDaDoSz81giL7zPpZH2Z35tbOrAJkkjMqOupg=
go.etcd.io/etcd/client/v3 v3.5.14/go.mod h1:k3XfdV/VIHy/97rqWjoUzrj9tk7GgJGH9J8L4dNXmAk=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
Expand Down

0 comments on commit 6ebc231

Please sign in to comment.