Add some comments
This commit is contained in:
parent
6b7f2f3bd3
commit
146701eeaa
@ -1,5 +1,8 @@
|
|||||||
package registry
|
package registry
|
||||||
|
|
||||||
|
// The registry provides an interface for service discovery
|
||||||
|
// and an abstraction over varying implementations
|
||||||
|
// {consul, etcd, zookeeper, ...}
|
||||||
type Registry interface {
|
type Registry interface {
|
||||||
Register(*Service, ...RegisterOption) error
|
Register(*Service, ...RegisterOption) error
|
||||||
Deregister(*Service) error
|
Deregister(*Service) error
|
||||||
@ -21,22 +24,27 @@ func NewRegistry(addrs []string, opt ...Option) Registry {
|
|||||||
return newConsulRegistry(addrs, opt...)
|
return newConsulRegistry(addrs, opt...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register a service node. Additionally supply options such as TTL.
|
||||||
func Register(s *Service, opts ...RegisterOption) error {
|
func Register(s *Service, opts ...RegisterOption) error {
|
||||||
return DefaultRegistry.Register(s, opts...)
|
return DefaultRegistry.Register(s, opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deregister a service node
|
||||||
func Deregister(s *Service) error {
|
func Deregister(s *Service) error {
|
||||||
return DefaultRegistry.Deregister(s)
|
return DefaultRegistry.Deregister(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Retrieve a service. A slice is returned since we separate Name/Version.
|
||||||
func GetService(name string) ([]*Service, error) {
|
func GetService(name string) ([]*Service, error) {
|
||||||
return DefaultRegistry.GetService(name)
|
return DefaultRegistry.GetService(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// List the services. Only returns service names
|
||||||
func ListServices() ([]*Service, error) {
|
func ListServices() ([]*Service, error) {
|
||||||
return DefaultRegistry.ListServices()
|
return DefaultRegistry.ListServices()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Watch returns a watcher which allows you to track updates to the registry.
|
||||||
func Watch() (Watcher, error) {
|
func Watch() (Watcher, error) {
|
||||||
return DefaultRegistry.Watch()
|
return DefaultRegistry.Watch()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user