Commit de4fe148 by 孙龙

up

parent 87d003c3
...@@ -23,4 +23,5 @@ ...@@ -23,4 +23,5 @@
addrs = [ addrs = [
"192.168.2.232:2379" "192.168.2.232:2379"
] ]
username = ""
password = "" password = ""
...@@ -26,6 +26,7 @@ func registryEtcd(){ ...@@ -26,6 +26,7 @@ func registryEtcd(){
//registry.WithAddrs([]string{"192.168.2.232:2379"}), //registry.WithAddrs([]string{"192.168.2.232:2379"}),
registry.WithAddrs(lib.GetStringSliceConf("base.etcd.addrs")), registry.WithAddrs(lib.GetStringSliceConf("base.etcd.addrs")),
registry.WithTimeout(5*time.Second), registry.WithTimeout(5*time.Second),
registry.WithUsername("base.etcd.username"),
registry.WithPasswrod("base.etcd.password"), registry.WithPasswrod("base.etcd.password"),
registry.WithRegistryPath("/ichuntMicroService/"), registry.WithRegistryPath("/ichuntMicroService/"),
registry.WithHeartBeat(5), registry.WithHeartBeat(5),
......
...@@ -82,6 +82,8 @@ func (e *EtcdRegistry) Init(ctx context.Context, opts ...registry.Option) (err e ...@@ -82,6 +82,8 @@ func (e *EtcdRegistry) Init(ctx context.Context, opts ...registry.Option) (err e
Endpoints: e.options.Addrs, Endpoints: e.options.Addrs,
DialTimeout: e.options.Timeout, DialTimeout: e.options.Timeout,
Password: e.options.Password, Password: e.options.Password,
Username: e.options.Username,
} }
e.client, err = clientv3.New(clientConfig) e.client, err = clientv3.New(clientConfig)
......
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
type Options struct { type Options struct {
Addrs []string Addrs []string
Timeout time.Duration Timeout time.Duration
Username string
Password string Password string
// example: /xxx_company/app/kuaishou/service_A/10.192.1.1:8801 // example: /xxx_company/app/kuaishou/service_A/10.192.1.1:8801
// example: /xxx_company/app/kuaishou/service_A/10.192.1.2:8801 // example: /xxx_company/app/kuaishou/service_A/10.192.1.2:8801
...@@ -34,6 +35,12 @@ func WithPasswrod(password string) Option { ...@@ -34,6 +35,12 @@ func WithPasswrod(password string) Option {
} }
} }
func WithUsername(username string) Option {
return func(opts *Options) {
opts.Username = username
}
}
func WithRegistryPath(path string) Option { func WithRegistryPath(path string) Option {
return func(opts *Options) { return func(opts *Options) {
opts.RegistryPath = path opts.RegistryPath = path
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment