Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(zookeeper-registry): Support the options of WithoutKeepAlive for zookeeper(#86) #87

Closed
wants to merge 9 commits into from
22 changes: 17 additions & 5 deletions registries/zookeeper/registry/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ import (
)

type Options struct {
Servers []string
RegistryGroup string
Username string
Password string
SessionTimeout time.Duration
Servers []string
RegistryGroup string
Username string
Password string
CloseRenewLease bool //
DMwangnima marked this conversation as resolved.
Show resolved Hide resolved
SessionTimeout time.Duration
}

func (o *Options) Apply(opts []Option) {
Expand Down Expand Up @@ -105,3 +106,14 @@ func WithPassword(password string) Option {
o.Password = password
}}
}

// WithHasRenewLease configures the RenewLease so that .You can control whether to enable
DMwangnima marked this conversation as resolved.
Show resolved Hide resolved
// 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 {
return Option{F: func(o *Options) {
DMwangnima marked this conversation as resolved.
Show resolved Hide resolved
o.CloseRenewLease = isRenew
}}
}
6 changes: 5 additions & 1 deletion registries/zookeeper/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ func (z *zookeeperRegistry) Register(info *registry.Info) error {
}
ctx, cancel := context.WithCancel(context.Background())
z.canceler.add(finalPath, cancel)
go z.keepalive(ctx, finalPath, nil)

if !z.opt.CloseRenewLease {
DMwangnima marked this conversation as resolved.
Show resolved Hide resolved
go z.keepalive(ctx, finalPath, nil)
}

return nil
}

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

type Options struct {
Servers []string
RegistryGroup string
SessionTimeout time.Duration
Username string
Password string
Servers []string
RegistryGroup string
SessionTimeout time.Duration
Username string
Password string
CloseRenewLease bool
DMwangnima marked this conversation as resolved.
Show resolved Hide resolved
}

func (o *Options) Apply(opts []Option) {
Expand Down Expand Up @@ -105,3 +106,12 @@ func WithPassword(password string) Option {
o.Password = password
}}
}

// WithHasRenewLease 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 {
DMwangnima marked this conversation as resolved.
Show resolved Hide resolved
return Option{F: func(o *Options) {
o.CloseRenewLease = isRenew
}}
}
Loading