Commit 83dea17d by 孙龙

up

parent 31a874d6
/go.sum /go.sum
/cmd/* /cmd/*
/logs/* /logs/*
/logs
...@@ -23,8 +23,8 @@ func HttpServerRun() { ...@@ -23,8 +23,8 @@ func HttpServerRun() {
r := InitRouter(middleware.RecoveryMiddleware(), r := InitRouter(middleware.RecoveryMiddleware(),
middleware.RequestLog()) middleware.RequestLog())
HttpSrvHandler = &http.Server{ HttpSrvHandler = &http.Server{
//Addr: lib.GetStringConf("proxy.http.addr"), Addr: lib.GetStringConf("proxy.http.addr"),
Addr: "192.168.1.234:2002", //Addr: "192.168.1.234:2002",
Handler: r, Handler: r,
ReadTimeout: time.Duration(lib.GetIntConf("proxy.http.read_timeout")) * time.Second, ReadTimeout: time.Duration(lib.GetIntConf("proxy.http.read_timeout")) * time.Second,
WriteTimeout: time.Duration(lib.GetIntConf("proxy.http.write_timeout")) * time.Second, WriteTimeout: time.Duration(lib.GetIntConf("proxy.http.write_timeout")) * time.Second,
......
The file could not be displayed because it is too large.
...@@ -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.WithPasswrod(""),
registry.WithRegistryPath("/ichuntMicroService/"), registry.WithRegistryPath("/ichuntMicroService/"),
registry.WithHeartBeat(5), registry.WithHeartBeat(5),
) )
......
...@@ -81,6 +81,7 @@ func (e *EtcdRegistry) Init(ctx context.Context, opts ...registry.Option) (err e ...@@ -81,6 +81,7 @@ func (e *EtcdRegistry) Init(ctx context.Context, opts ...registry.Option) (err e
clientConfig := clientv3.Config{ clientConfig := clientv3.Config{
Endpoints: e.options.Addrs, Endpoints: e.options.Addrs,
DialTimeout: e.options.Timeout, DialTimeout: e.options.Timeout,
Password: e.options.Password,
} }
e.client, err = clientv3.New(clientConfig) e.client, err = clientv3.New(clientConfig)
......
...@@ -100,6 +100,7 @@ func TestGetService(t *testing.T){ ...@@ -100,6 +100,7 @@ func TestGetService(t *testing.T){
registryInst, err := registry.InitRegistry(context.TODO(), "etcd", registryInst, err := registry.InitRegistry(context.TODO(), "etcd",
registry.WithAddrs([]string{"192.168.2.232:2379"}), registry.WithAddrs([]string{"192.168.2.232:2379"}),
registry.WithTimeout(time.Second), registry.WithTimeout(time.Second),
registry.WithPasswrod(""),
registry.WithRegistryPath("/ichuntMicroService/"), registry.WithRegistryPath("/ichuntMicroService/"),
registry.WithHeartBeat(5), registry.WithHeartBeat(5),
) )
......
...@@ -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
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
RegistryPath string RegistryPath string
...@@ -27,6 +28,12 @@ func WithAddrs(addrs []string) Option { ...@@ -27,6 +28,12 @@ func WithAddrs(addrs []string) Option {
} }
} }
func WithPasswrod(password string) Option {
return func(opts *Options) {
opts.Password = password
}
}
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