Service and node should be structs rather than interface

This commit is contained in:
Asim
2015-05-25 22:14:28 +01:00
parent d4a7deb594
commit 7aa2c82ced
14 changed files with 140 additions and 231 deletions

View File

@@ -1,12 +1,23 @@
package registry
type Registry interface {
Register(Service) error
Deregister(Service) error
GetService(string) (Service, error)
ListServices() ([]Service, error)
NewService(string, ...Node) Service
NewNode(string, string, int) Node
Register(*Service) error
Deregister(*Service) error
GetService(string) (*Service, error)
ListServices() ([]*Service, error)
}
type Service struct {
Name string
MetaData map[string]string
Nodes []*Node
}
type Node struct {
Id string
Address string
Port int
MetaData map[string]string
}
type options struct{}
@@ -21,18 +32,18 @@ func NewRegistry(addrs []string, opt ...Option) Registry {
return newConsulRegistry(addrs, opt...)
}
func Register(s Service) error {
func Register(s *Service) error {
return DefaultRegistry.Register(s)
}
func Deregister(s Service) error {
func Deregister(s *Service) error {
return DefaultRegistry.Deregister(s)
}
func GetService(name string) (Service, error) {
func GetService(name string) (*Service, error) {
return DefaultRegistry.GetService(name)
}
func ListServices() ([]Service, error) {
func ListServices() ([]*Service, error) {
return DefaultRegistry.ListServices()
}