registry: add noop registry

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-08-29 17:41:49 +03:00
parent eb1b14da8a
commit dd8894e673

44
registry/noop.go Normal file
View File

@ -0,0 +1,44 @@
package registry
import (
"errors"
)
type noopRegistry struct{}
func (n *noopRegistry) Init(...Option) error {
return nil
}
func (n *noopRegistry) Options() Options {
return Options{}
}
func (n *noopRegistry) Register(*Service, ...RegisterOption) error {
return nil
}
func (n *noopRegistry) Deregister(*Service, ...DeregisterOption) error {
return nil
}
func (n *noopRegistry) GetService(string, ...GetOption) ([]*Service, error) {
return []*Service{}, nil
}
func (n *noopRegistry) ListServices(...ListOption) ([]*Service, error) {
return []*Service{}, nil
}
func (n *noopRegistry) Watch(...WatchOption) (Watcher, error) {
return nil, errors.New("not implemented")
}
func (n *noopRegistry) String() string {
return "noop"
}
// NewRegistry returns a new noop registry
func NewRegistry(...Option) Registry {
return &noopRegistry{}
}