Skip to content

Commit

Permalink
fix(resolve): Review adjust (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
s5364733 committed Mar 27, 2024
1 parent 498a6bf commit fda689e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
18 changes: 9 additions & 9 deletions registries/zookeeper/registry/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import (
)

type Options struct {
Servers []string
RegistryGroup string
Username string
Password string
CloseRenewLease bool //
SessionTimeout time.Duration
Servers []string
RegistryGroup string
Username string
Password string
RenewNodeLease bool //
SessionTimeout time.Duration
}

func (o *Options) Apply(opts []Option) {
Expand Down Expand Up @@ -107,13 +107,13 @@ func WithPassword(password string) Option {
}}
}

// WithHasRenewLease configures the RenewLease so that .You can control whether to enable
// WithoutRenewNodeLease configures the RenewLease so that .You can control whether to enable
// the renewal of the Ephemeral node, which is very helpful for debugging the
// development environment.
// Default keep here is ,for details please refer to
// https://github.com/kitex-contrib/codec-dubbo/issues/86
func WithHasRenewLease(isRenew bool) Option {
func WithoutRenewNodeLease(renewNodeLease bool) Option {
return Option{F: func(o *Options) {
o.CloseRenewLease = isRenew
o.RenewNodeLease = renewNodeLease
}}
}
2 changes: 1 addition & 1 deletion registries/zookeeper/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (z *zookeeperRegistry) Register(info *registry.Info) error {
ctx, cancel := context.WithCancel(context.Background())
z.canceler.add(finalPath, cancel)

if !z.opt.CloseRenewLease {
if !z.opt.RenewNodeLease {
go z.keepalive(ctx, finalPath, nil)
}

Expand Down
23 changes: 14 additions & 9 deletions registries/zookeeper/resolver/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import (
)

type Options struct {
Servers []string
RegistryGroup string
SessionTimeout time.Duration
Username string
Password string
CloseRenewLease bool
Servers []string
RegistryGroup string
SessionTimeout time.Duration
Username string
Password string
RenewNodeLease bool //
}

func (o *Options) Apply(opts []Option) {
Expand Down Expand Up @@ -107,11 +107,16 @@ func WithPassword(password string) Option {
}}
}

// WithHasRenewLease configures the RenewLease so that .You can control whether to enable
// WithoutRenewNodeLease configures the RenewLease so that .You can control whether to enable
// the renewal of the Ephemeral node, which is very helpful for debugging the
// development environment.
func WithHasRenewLease(isRenew bool) Option {
// Default keep here is ,for details please refer to
// https://github.com/kitex-contrib/codec-dubbo/issues/86
// If you want to enable it, you can use the following code:
//
// zookeeperResolver, err := resolver.NewZookeeperResolver(resolver.WithoutRenewNodeLease(true))
func WithoutRenewNodeLease(renewNodeLease bool) Option {
return Option{F: func(o *Options) {
o.CloseRenewLease = isRenew
o.RenewNodeLease = renewNodeLease
}}
}

0 comments on commit fda689e

Please sign in to comment.