Move global vars to the top of the src file: conventions

This commit is contained in:
Milos Gajdos 2019-09-23 20:46:12 +01:00
parent 0ec1b840fd
commit 04a5d884da
No known key found for this signature in database
GPG Key ID: 8B31058CC55DFD4F

View File

@ -5,6 +5,15 @@ import (
"errors"
)
var (
DefaultRegistry = NewRegistry()
// Not found error when GetService is called
ErrNotFound = errors.New("service not found")
// Watcher stopped error when watcher is stopped
ErrWatcherStopped = errors.New("watcher stopped")
)
// The registry provides an interface for service discovery
// and an abstraction over varying implementations
// {consul, etcd, zookeeper, ...}
@ -25,15 +34,6 @@ type RegisterOption func(*RegisterOptions)
type WatchOption func(*WatchOptions)
var (
DefaultRegistry = NewRegistry()
// Not found error when GetService is called
ErrNotFound = errors.New("service not found")
// Watcher stopped error when watcher is stopped
ErrWatcherStopped = errors.New("watcher stopped")
)
// Register a service node. Additionally supply options such as TTL.
func Register(s *Service, opts ...RegisterOption) error {
return DefaultRegistry.Register(s, opts...)