chore: refactor config center (#4339)

Signed-off-by: kevin <wanjunfeng@gmail.com>
This commit is contained in:
Kevin Wan
2024-08-28 20:02:48 +08:00
committed by GitHub
parent 44cddec5c3
commit 24d6150073
6 changed files with 90 additions and 93 deletions

View File

@@ -15,10 +15,10 @@ type (
// A Subscriber is used to subscribe the given key on an etcd cluster.
Subscriber struct {
endpoints []string
exclusive bool
disablePrefix bool
items *container
endpoints []string
exclusive bool
exactMatch bool
items *container
}
)
@@ -35,7 +35,7 @@ func NewSubscriber(endpoints []string, key string, opts ...SubOption) (*Subscrib
}
sub.items = newContainer(sub.exclusive)
if err := internal.GetRegistry().Monitor(endpoints, key, sub.items, sub.disablePrefix); err != nil {
if err := internal.GetRegistry().Monitor(endpoints, key, sub.items, sub.exactMatch); err != nil {
return nil, err
}
@@ -60,10 +60,10 @@ func Exclusive() SubOption {
}
}
// WithDisablePrefix turn off querying using key prefixes.
func WithDisablePrefix() SubOption {
// WithExactMatch turn off querying using key prefixes.
func WithExactMatch() SubOption {
return func(sub *Subscriber) {
sub.disablePrefix = true
sub.exactMatch = true
}
}