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 DeregisterOption
- type DeregisterOptions
- 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 Result
- type Service
- type Value
- type WatchOption
- type WatchOptions
- type Watcher
Constants ¶
This section is empty.
Variables ¶
var ( // 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") )
var (
DefaultRegistry = NewMDNSRegistry()
)
Functions ¶
func Register ¶
func Register(s *Service, opts ...RegisterOption) error
Register a service node. Additionally supply options such as TTL.
Types ¶
type DeregisterOption ¶
type DeregisterOption func(*DeregisterOptions)
func DeregisterContext ¶
func DeregisterContext(ctx context.Context) DeregisterOption
type Endpoint ¶
type Event ¶
type Event struct {
// Timestamp is event timestamp
Timestamp time.Time
// Service is registry service
Service *Service
// Id is registry id
Id string
// Type defines type of event
Type EventType
}
Event is registry event.
type GetOption ¶
type GetOption func(*GetOptions)
type ListOption ¶
type ListOption func(*ListOptions)
func ListContext ¶
func ListContext(ctx context.Context) ListOption
type Node ¶
type Option ¶
type Option func(*Options)
func Services ¶
Services is an option that preloads service data.
type Options ¶
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 NewMDNSRegistry ¶
NewRegistry returns a new default registry which is mdns.
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.
type Value ¶
type WatchOption ¶
type WatchOption func(*WatchOptions)
func WatchContext ¶
func WatchContext(ctx context.Context) WatchOption
type WatchOptions ¶
type Watcher ¶
Watcher is an interface that returns updates about services within the registry.
func Watch ¶
func Watch(opts ...WatchOption) (Watcher, error)
Watch returns a watcher which allows you to track updates to the registry.
Source Files
¶
- mdns_registry.go
- memory.go
- memory_util.go
- memory_watcher.go
- options.go
- registry.go
- watcher.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cache provides a registry cache
|
Package cache provides a registry cache |
|
Package etcd provides an etcd service registry
|
Package etcd provides an etcd service registry |
|
Package nats provides a NATS registry using broadcast queries
|
Package nats provides a NATS registry using broadcast queries |