mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-11 00:40:00 +08:00
feat: added configuration center function (#3035)
Co-authored-by: aiden.ma <Aiden.ma@yijinin.com>
This commit is contained in:
@@ -15,9 +15,10 @@ type (
|
||||
|
||||
// A Subscriber is used to subscribe the given key on an etcd cluster.
|
||||
Subscriber struct {
|
||||
endpoints []string
|
||||
exclusive bool
|
||||
items *container
|
||||
endpoints []string
|
||||
exclusive bool
|
||||
disablePrefix bool
|
||||
items *container
|
||||
}
|
||||
)
|
||||
|
||||
@@ -34,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); err != nil {
|
||||
if err := internal.GetRegistry().Monitor(endpoints, key, sub.items, sub.disablePrefix); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -59,6 +60,13 @@ func Exclusive() SubOption {
|
||||
}
|
||||
}
|
||||
|
||||
// WithDisablePrefix turn off querying using key prefixes.
|
||||
func WithDisablePrefix() SubOption {
|
||||
return func(sub *Subscriber) {
|
||||
sub.disablePrefix = true
|
||||
}
|
||||
}
|
||||
|
||||
// WithSubEtcdAccount provides the etcd username/password.
|
||||
func WithSubEtcdAccount(user, pass string) SubOption {
|
||||
return func(sub *Subscriber) {
|
||||
|
||||
Reference in New Issue
Block a user