Commit 83dea17d by 孙龙

up

parent 31a874d6
/go.sum
/cmd/*
/logs/*
/logs
......@@ -23,8 +23,8 @@ func HttpServerRun() {
r := InitRouter(middleware.RecoveryMiddleware(),
middleware.RequestLog())
HttpSrvHandler = &http.Server{
//Addr: lib.GetStringConf("proxy.http.addr"),
Addr: "192.168.1.234:2002",
Addr: lib.GetStringConf("proxy.http.addr"),
//Addr: "192.168.1.234:2002",
Handler: r,
ReadTimeout: time.Duration(lib.GetIntConf("proxy.http.read_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(){
//registry.WithAddrs([]string{"192.168.2.232:2379"}),
registry.WithAddrs(lib.GetStringSliceConf("base.etcd.addrs")),
registry.WithTimeout(5*time.Second),
registry.WithPasswrod(""),
registry.WithRegistryPath("/ichuntMicroService/"),
registry.WithHeartBeat(5),
)
......
......@@ -81,6 +81,7 @@ func (e *EtcdRegistry) Init(ctx context.Context, opts ...registry.Option) (err e
clientConfig := clientv3.Config{
Endpoints: e.options.Addrs,
DialTimeout: e.options.Timeout,
Password: e.options.Password,
}
e.client, err = clientv3.New(clientConfig)
......
......@@ -100,6 +100,7 @@ func TestGetService(t *testing.T){
registryInst, err := registry.InitRegistry(context.TODO(), "etcd",
registry.WithAddrs([]string{"192.168.2.232:2379"}),
registry.WithTimeout(time.Second),
registry.WithPasswrod(""),
registry.WithRegistryPath("/ichuntMicroService/"),
registry.WithHeartBeat(5),
)
......
......@@ -7,6 +7,7 @@ import (
type Options struct {
Addrs []string
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.2:8801
RegistryPath string
......@@ -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 {
return func(opts *Options) {
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