Documentation ¶
Overview ¶
Package mdns is a multicast dns registry
Package registry is an interface for service discovery
Index ¶
- Variables
- func Deregister(s *Service) error
- func Register(s *Service, opts ...RegisterOption) error
- func String() string
- type Config
- type ConfigStore
- type DeregisterOption
- type DeregisterOptions
- type DiConfig
- type DiFlags
- type Endpoint
- type Event
- type EventType
- type GetOption
- type GetOptions
- type ListOption
- type ListOptions
- type Node
- type Option
- type Options
- type RegisterOption
- type RegisterOptions
- type Registry
- type RegistryConfig
- type Result
- type Service
- type Value
- type WatchOption
- type WatchOptions
- type Watcher
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultRegistry = NewRegistry() // Not found error when GetService is called. ErrNotFound = errors.New("service not found") // Watcher stopped error when watcher is stopped. ErrWatcherStopped = errors.New("watcher stopped") )
View Source
var DiNoCliSet = wire.NewSet(ProvideConfigNoFlags, Provide)
View Source
var DiSet = wire.NewSet(ProvideFlags, ProvideConfig, Provide)
View Source
var Plugins = generic.NewContainer(func(opts ...Option) Registry { return nil })
Functions ¶
func Register ¶
func Register(s *Service, opts ...RegisterOption) error
Register a service node. Additionally supply options such as TTL.
Types ¶
type Config ¶
type Config struct {
Registry RegistryConfig `json:"broker" yaml:"Registry"`
}
type ConfigStore ¶
type ConfigStore struct { Enabled bool `json:"enabled" yaml:"Enabled"` Plugin string `json:"plugin,omitempty" yaml:"Plugin,omitempty"` Addresses []string `json:"addresses,omitempty" yaml:"Addresses,omitempty"` }
func NewConfigStore ¶
func NewConfigStore() ConfigStore
func (*ConfigStore) Merge ¶
func (d *ConfigStore) Merge(src *ConfigStore) error
type DeregisterOption ¶
type DeregisterOption func(*DeregisterOptions)
func DeregisterContext ¶
func DeregisterContext(ctx context.Context) DeregisterOption
type DeregisterOptions ¶
type DiConfig ¶
type DiConfig struct{}
DiConfig is marker that DiFlags has been parsed into Config
func ProvideConfig ¶
type Event ¶
type Event struct { // Id is registry id Id string // Type defines type of event Type EventType // Timestamp is event timestamp Timestamp time.Time // Service is registry service Service *Service }
Event is registry event.
type GetOptions ¶
type ListOption ¶
type ListOption func(*ListOptions)
func ListContext ¶
func ListContext(ctx context.Context) ListOption
type ListOptions ¶
type Option ¶
type Option func(*Options)
type Options ¶
type Options struct { Addrs []string Timeout time.Duration Secure bool TLSConfig *tls.Config Logger logger.Logger // Other options for implementations of the interface // can be stored in a context Context context.Context }
func NewOptions ¶
type RegisterOption ¶
type RegisterOption func(*RegisterOptions)
func RegisterContext ¶
func RegisterContext(ctx context.Context) RegisterOption
func RegisterTTL ¶
func RegisterTTL(t time.Duration) RegisterOption
type RegisterOptions ¶
type Registry ¶
type Registry interface { Init(...Option) error Options() Options Register(*Service, ...RegisterOption) error Deregister(*Service, ...DeregisterOption) error GetService(string, ...GetOption) ([]*Service, error) ListServices(...ListOption) ([]*Service, error) Watch(...WatchOption) (Watcher, error) String() string }
The registry provides an interface for service discovery and an abstraction over varying implementations {consul, etcd, zookeeper, ...}.
func NewMemoryRegistry ¶
func NewRegistry ¶
NewRegistry returns a new default registry which is mdns.
type RegistryConfig ¶
type Result ¶
Result is returned by a call to Next on the watcher. Actions can be create, update, delete.
type Service ¶
type Service struct { Name string `json:"name"` Version string `json:"version"` Metadata map[string]string `json:"metadata"` Endpoints []*Endpoint `json:"endpoints"` Nodes []*Node `json:"nodes"` }
func GetService ¶
Retrieve a service. A slice is returned since we separate Name/Version.
func ListServices ¶
List the services. Only returns service names.
type WatchOption ¶
type WatchOption func(*WatchOptions)
func WatchContext ¶
func WatchContext(ctx context.Context) WatchOption
type WatchOptions ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.