micro/registry/noop.go
Vasiliy Tolstov 14c97d59c1 many improvements with options and noop stuff
* add many options helpers
* fix noop client to allow publish messages to topic in broker
* fix noop server to allow registering in registry
* fix noop server to allow subscribe to topic in broker
* fix new service initialization

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2020-10-16 09:38:57 +03:00

60 lines
1.1 KiB
Go

package registry
import (
"context"
"fmt"
)
type NoopRegistry struct {
opts Options
}
func (n *NoopRegistry) Init(opts ...Option) error {
for _, o := range opts {
o(&n.opts)
}
return nil
}
func (n *NoopRegistry) Options() Options {
return n.opts
}
func (n *NoopRegistry) Connect(ctx context.Context) error {
return nil
}
func (n *NoopRegistry) Disconnect(ctx context.Context) error {
return nil
}
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, fmt.Errorf("not implemented")
}
func (n *NoopRegistry) String() string {
return "noop"
}
// NewRegistry returns a new noop registry
func NewRegistry(opts ...Option) Registry {
options := NewOptions(opts...)
return &NoopRegistry{opts: options}
}