Skip to content

Commit

Permalink
chore: coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan committed May 6, 2024
1 parent 403cec0 commit 4c13f14
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions zrpc/resolver/internal/discovbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,26 @@ func (b *discovBuilder) Scheme() string {

func (b *discovBuilder) updateState(target resolver.Target) error {
if b.update == nil {
if err := b.buildEndpointsUpdater(target); err != 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) error {
func (b *discovBuilder) buildEndpointsUpdater(target resolver.Target) (func(), error) {
hosts := strings.FieldsFunc(targets.GetAuthority(target), func(r rune) bool {
return r == EndpointSepChar
})
sub, err := discov.NewSubscriber(hosts, targets.GetEndpoints(target))
if err != nil {
return err
return nil, err
}

update := func() {
Expand All @@ -63,7 +66,6 @@ func (b *discovBuilder) buildEndpointsUpdater(target resolver.Target) error {
}
}
sub.AddListener(update)
b.update = update

return nil
return update, nil
}

0 comments on commit 4c13f14

Please sign in to comment.