2020-08-29 17:41:49 +03:00
|
|
|
package registry
|
|
|
|
|
2020-10-16 09:38:57 +03:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
)
|
2020-08-29 17:41:49 +03:00
|
|
|
|
2020-10-16 09:38:57 +03:00
|
|
|
type NoopRegistry struct {
|
2020-09-03 15:11:05 +03:00
|
|
|
opts Options
|
|
|
|
}
|
2020-08-29 17:41:49 +03:00
|
|
|
|
2020-10-16 09:38:57 +03:00
|
|
|
func (n *NoopRegistry) Init(opts ...Option) error {
|
2020-09-03 15:11:05 +03:00
|
|
|
for _, o := range opts {
|
|
|
|
o(&n.opts)
|
|
|
|
}
|
2020-08-29 17:41:49 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-10-16 09:38:57 +03:00
|
|
|
func (n *NoopRegistry) Options() Options {
|
2020-09-03 15:11:05 +03:00
|
|
|
return n.opts
|
2020-08-29 17:41:49 +03:00
|
|
|
}
|
|
|
|
|
2020-10-16 09:38:57 +03:00
|
|
|
func (n *NoopRegistry) Connect(ctx context.Context) error {
|
2020-08-29 17:41:49 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-10-16 09:38:57 +03:00
|
|
|
func (n *NoopRegistry) Disconnect(ctx context.Context) error {
|
2020-08-29 17:41:49 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-10-16 09:38:57 +03:00
|
|
|
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) {
|
2020-08-29 17:41:49 +03:00
|
|
|
return []*Service{}, nil
|
|
|
|
}
|
|
|
|
|
2020-10-16 09:38:57 +03:00
|
|
|
func (n *NoopRegistry) ListServices(...ListOption) ([]*Service, error) {
|
2020-08-29 17:41:49 +03:00
|
|
|
return []*Service{}, nil
|
|
|
|
}
|
|
|
|
|
2020-10-16 09:38:57 +03:00
|
|
|
func (n *NoopRegistry) Watch(...WatchOption) (Watcher, error) {
|
2020-09-03 15:11:05 +03:00
|
|
|
return nil, fmt.Errorf("not implemented")
|
2020-08-29 17:41:49 +03:00
|
|
|
}
|
|
|
|
|
2020-10-16 09:38:57 +03:00
|
|
|
func (n *NoopRegistry) String() string {
|
2020-08-29 17:41:49 +03:00
|
|
|
return "noop"
|
|
|
|
}
|
|
|
|
|
2020-10-16 09:38:57 +03:00
|
|
|
// NewRegistry returns a new noop registry
|
|
|
|
func NewRegistry(opts ...Option) Registry {
|
|
|
|
options := NewOptions(opts...)
|
|
|
|
return &NoopRegistry{opts: options}
|
2020-08-29 17:41:49 +03:00
|
|
|
}
|