From 146701eeaab5aaaaa1aa600a14b0d2b2d10447d3 Mon Sep 17 00:00:00 2001 From: Asim Date: Sat, 30 Jan 2016 21:13:34 +0000 Subject: [PATCH] Add some comments --- registry/registry.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/registry/registry.go b/registry/registry.go index 5f8dd336..93284c28 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -1,5 +1,8 @@ package registry +// The registry provides an interface for service discovery +// and an abstraction over varying implementations +// {consul, etcd, zookeeper, ...} type Registry interface { Register(*Service, ...RegisterOption) error Deregister(*Service) error @@ -21,22 +24,27 @@ func NewRegistry(addrs []string, opt ...Option) Registry { return newConsulRegistry(addrs, opt...) } +// Register a service node. Additionally supply options such as TTL. func Register(s *Service, opts ...RegisterOption) error { return DefaultRegistry.Register(s, opts...) } +// Deregister a service node func Deregister(s *Service) error { return DefaultRegistry.Deregister(s) } +// Retrieve a service. A slice is returned since we separate Name/Version. func GetService(name string) ([]*Service, error) { return DefaultRegistry.GetService(name) } +// List the services. Only returns service names func ListServices() ([]*Service, error) { return DefaultRegistry.ListServices() } +// Watch returns a watcher which allows you to track updates to the registry. func Watch() (Watcher, error) { return DefaultRegistry.Watch() }