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-11-03 01:04:56 +03:00
|
|
|
type noopRegistry struct {
|
2020-09-03 15:11:05 +03:00
|
|
|
opts Options
|
|
|
|
}
|
2020-08-29 17:41:49 +03:00
|
|
|
|
2020-11-03 01:04:56 +03:00
|
|
|
// Init initialize registry
|
|
|
|
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-11-03 01:04:56 +03:00
|
|
|
// Options returns options struct
|
|
|
|
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-11-03 01:04:56 +03:00
|
|
|
// Connect opens connection to registry
|
|
|
|
func (n *noopRegistry) Connect(ctx context.Context) error {
|
2020-08-29 17:41:49 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-03 01:04:56 +03:00
|
|
|
// Disconnect close connection to registry
|
|
|
|
func (n *noopRegistry) Disconnect(ctx context.Context) error {
|
2020-08-29 17:41:49 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-03 01:04:56 +03:00
|
|
|
// Register registers service
|
|
|
|
func (n *noopRegistry) Register(*Service, ...RegisterOption) error {
|
2020-10-16 09:38:57 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-03 01:04:56 +03:00
|
|
|
// Deregister deregisters service
|
|
|
|
func (n *noopRegistry) Deregister(*Service, ...DeregisterOption) error {
|
2020-10-16 09:38:57 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-03 01:04:56 +03:00
|
|
|
// GetService returns servive info
|
|
|
|
func (n *noopRegistry) GetService(string, ...GetOption) ([]*Service, error) {
|
2020-08-29 17:41:49 +03:00
|
|
|
return []*Service{}, nil
|
|
|
|
}
|
|
|
|
|
2020-11-03 01:04:56 +03:00
|
|
|
// ListServices listing services
|
|
|
|
func (n *noopRegistry) ListServices(...ListOption) ([]*Service, error) {
|
2020-08-29 17:41:49 +03:00
|
|
|
return []*Service{}, nil
|
|
|
|
}
|
|
|
|
|
2020-11-03 01:04:56 +03:00
|
|
|
// Watch is used to watch for service changes
|
|
|
|
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-11-03 01:04:56 +03:00
|
|
|
// String returns registry string representation
|
|
|
|
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 {
|
2020-11-03 01:04:56 +03:00
|
|
|
return &noopRegistry{opts: NewOptions(opts...)}
|
2020-08-29 17:41:49 +03:00
|
|
|
}
|