Skip to content

Commit

Permalink
fix(registry/zookeeper): watch service name path error with extra suf…
Browse files Browse the repository at this point in the history
…fix `-` (gogf#3948)
  • Loading branch information
cruelchen authored Nov 20, 2024
1 parent 3090fe7 commit 9085188
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion contrib/registry/zookeeper/zookeeper_registrar.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (r *Registry) Register(_ context.Context, service gsvc.Service) (gsvc.Servi
// Deregister off-lines and removes `service` from the Registry.
func (r *Registry) Deregister(ctx context.Context, service gsvc.Service) error {
ch := make(chan error, 1)
prefix := strings.TrimPrefix(strings.ReplaceAll(service.GetPrefix(), "/", "-"), "-")
prefix := strings.Trim(strings.ReplaceAll(service.GetPrefix(), "/", "-"), "-")
servicePath := path.Join(r.opts.namespace, prefix, service.GetName())
go func() {
err := r.conn.Delete(servicePath, -1)
Expand Down
4 changes: 2 additions & 2 deletions contrib/registry/zookeeper/zookeeper_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (w *watcher) Proceed() ([]gsvc.Service, error) {
}

func (w *watcher) getServicesByPrefix() ([]gsvc.Service, error) {
prefix := strings.TrimPrefix(strings.ReplaceAll(w.prefix, "/", "-"), "-")
prefix := strings.Trim(strings.ReplaceAll(w.prefix, "/", "-"), "-")
serviceNamePath := path.Join(w.nameSpace, prefix)
instances, err, _ := w.group.Do(serviceNamePath, func() (interface{}, error) {
servicesID, _, err := w.conn.Children(serviceNamePath)
Expand Down Expand Up @@ -122,7 +122,7 @@ func (w *watcher) Close() error {
}

func (w *watcher) watch(ctx context.Context) {
prefix := strings.TrimPrefix(strings.ReplaceAll(w.prefix, "/", "-"), "-")
prefix := strings.Trim(strings.ReplaceAll(w.prefix, "/", "-"), "-")
serviceNamePath := path.Join(w.nameSpace, prefix)
for {

Expand Down

0 comments on commit 9085188

Please sign in to comment.