func NewRegistry(opts ...registry.Option) registry.Registry { config := clientv3.Config{ Endpoints: []string{"127.0.0.1:2379"}, } var options registry.Options for _, o := range opts { o(&options) } if options.Timeout == 0 { options.Timeout = 5 * time.Second } if options.Secure || options.TLSConfig != nil { tlsConfig := options.TLSConfig if tlsConfig == nil { tlsConfig = &tls.Config{ InsecureSkipVerify: true, } } config.TLS = tlsConfig } var cAddrs []string for _, addr := range options.Addrs { if len(addr) == 0 { continue } cAddrs = append(cAddrs, addr) } // if we got addrs then we'll update if len(cAddrs) > 0 { config.Endpoints = cAddrs } cli, _ := clientv3.New(config) e := &etcdv3Registry{ client: cli, options: options, register: make(map[string]uint64), leases: make(map[string]clientv3.LeaseID), } return e }