mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
discovery: add clarifying docstrings
This commit is contained in:
parent
ab00d23cd3
commit
bb84aaebaf
@ -53,6 +53,8 @@ const (
|
||||
)
|
||||
|
||||
type Discoverer interface {
|
||||
// Discover connects to a discovery service and retrieves a string
|
||||
// describing an etcd cluster, and any error encountered.
|
||||
Discover() (string, error)
|
||||
}
|
||||
|
||||
@ -67,7 +69,26 @@ type discovery struct {
|
||||
clock clockwork.Clock
|
||||
}
|
||||
|
||||
type proxyDiscovery struct{ *discovery }
|
||||
type proxyDiscovery struct {
|
||||
*discovery
|
||||
}
|
||||
|
||||
// New returns a Discoverer which will connect to the discovery service at
|
||||
// the given url, and register the server represented by the given id and
|
||||
// config to the cluster during the discovery process
|
||||
func New(durl string, id types.ID, config string) (Discoverer, error) {
|
||||
return newDiscovery(durl, id, config)
|
||||
}
|
||||
|
||||
// ProxyNew returns a Discoverer which will connect to the discovery service
|
||||
// at the given url and retrieve a string describing the cluster
|
||||
func ProxyNew(durl string) (Discoverer, error) {
|
||||
d, err := newDiscovery(durl, 0, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &proxyDiscovery{d}, nil
|
||||
}
|
||||
|
||||
// proxyFuncFromEnv builds a proxy function if the appropriate environment
|
||||
// variable is set. It performs basic sanitization of the environment variable
|
||||
@ -98,18 +119,6 @@ func proxyFuncFromEnv() (func(*http.Request) (*url.URL, error), error) {
|
||||
return http.ProxyURL(proxyURL), nil
|
||||
}
|
||||
|
||||
func New(durl string, id types.ID, config string) (Discoverer, error) {
|
||||
return newDiscovery(durl, id, config)
|
||||
}
|
||||
|
||||
func ProxyNew(durl string) (Discoverer, error) {
|
||||
d, err := newDiscovery(durl, 0, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &proxyDiscovery{d}, nil
|
||||
}
|
||||
|
||||
func newDiscovery(durl string, id types.ID, config string) (*discovery, error) {
|
||||
u, err := url.Parse(durl)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user