Skip to content

Commit

Permalink
Revert "fix: etcd scheme on grpc resolver (#4121)"
Browse files Browse the repository at this point in the history
This reverts commit 47d13e5.
  • Loading branch information
MarkJoyMa authored Sep 2, 2024
1 parent c92f788 commit ed2dbf1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 36 deletions.
42 changes: 8 additions & 34 deletions zrpc/resolver/internal/discovbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,10 @@ import (
"google.golang.org/grpc/resolver"
)

type discovBuilder struct {
cc resolver.ClientConn
update func()
}
type discovBuilder struct{}

func (b *discovBuilder) Build(target resolver.Target, cc resolver.ClientConn, _ resolver.BuildOptions) (
resolver.Resolver, error) {
b.cc = cc
if err := b.updateState(target); err != nil {
return nil, err
}

return &nopResolver{cc: cc}, nil
}

func (b *discovBuilder) Scheme() string {
return DiscovScheme
}

func (b *discovBuilder) updateState(target resolver.Target) error {
if b.update == nil {
update, err := b.buildEndpointsUpdater(target)
if err != nil {
return err
}

b.update = update
}

b.update()

return nil
}

func (b *discovBuilder) buildEndpointsUpdater(target resolver.Target) (func(), error) {
hosts := strings.FieldsFunc(targets.GetAuthority(target), func(r rune) bool {
return r == EndpointSepChar
})
Expand All @@ -60,13 +29,18 @@ func (b *discovBuilder) buildEndpointsUpdater(target resolver.Target) (func(), e
Addr: val,
})
}
if err := b.cc.UpdateState(resolver.State{
if err := cc.UpdateState(resolver.State{
Addresses: addrs,
}); err != nil {
logx.Error(err)
}
}
sub.AddListener(update)
update()

return update, nil
return &nopResolver{cc: cc}, nil
}

func (b *discovBuilder) Scheme() string {
return DiscovScheme
}
3 changes: 1 addition & 2 deletions zrpc/resolver/internal/kubebuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ type kubeResolver struct {
stopCh chan struct{}
}

func (r *kubeResolver) ResolveNow(_ resolver.ResolveNowOptions) {
}
func (r *kubeResolver) ResolveNow(_ resolver.ResolveNowOptions) {}

func (r *kubeResolver) start() {
threading.GoSafe(func() {
Expand Down

0 comments on commit ed2dbf1

Please sign in to comment.