mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
contrib/registry/zookeeper: fix invalid searching prefix (#3598)
This commit is contained in:
@ -19,7 +19,7 @@ import (
|
||||
|
||||
// Search searches and returns services with specified condition.
|
||||
func (r *Registry) Search(_ context.Context, in gsvc.SearchInput) ([]gsvc.Service, error) {
|
||||
prefix := strings.TrimPrefix(strings.ReplaceAll(in.Prefix, "/", "-"), "-")
|
||||
prefix := strings.Trim(strings.ReplaceAll(in.Prefix, "/", "-"), "-")
|
||||
instances, err, _ := r.group.Do(prefix, func() (interface{}, error) {
|
||||
serviceNamePath := path.Join(r.opts.namespace, prefix)
|
||||
servicesID, _, err := r.conn.Children(serviceNamePath)
|
||||
|
||||
@ -31,7 +31,7 @@ func (r *Registry) Register(_ context.Context, service gsvc.Service) (gsvc.Servi
|
||||
r.opts.namespace,
|
||||
)
|
||||
}
|
||||
prefix := strings.TrimPrefix(strings.ReplaceAll(service.GetPrefix(), "/", "-"), "-")
|
||||
prefix := strings.Trim(strings.ReplaceAll(service.GetPrefix(), "/", "-"), "-")
|
||||
servicePrefixPath := path.Join(r.opts.namespace, prefix)
|
||||
if err = r.ensureName(servicePrefixPath, []byte(""), 0); err != nil {
|
||||
return service, gerror.Wrapf(
|
||||
|
||||
Reference in New Issue
Block a user