Documentation ¶
Overview ¶
Package registry is an interface for service discovery
Index ¶
- Constants
- Variables
- 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 ¶
const ( // WildcardDomain indicates any domain WildcardDomain = "*" // DefaultDomain to use if none was provided in options DefaultDomain = "micro" )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type DeregisterOption ¶
type DeregisterOption func(*DeregisterOptions)
DeregisterOption option is used to deregister service
func DeregisterContext ¶
func DeregisterContext(ctx context.Context) DeregisterOption
func DeregisterDomain ¶
func DeregisterDomain(d string) DeregisterOption
type DeregisterOptions ¶
type Endpoint ¶
type Endpoint struct { Name string `json:"name"` Request *Value `json:"request"` Response *Value `json:"response"` Metadata map[string]string `json:"metadata"` }
Endpoint holds endpoint registry info
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 GetOption ¶
type GetOption func(*GetOptions)
GetOption option is used to get service
func GetContext ¶
type GetOptions ¶
type ListOption ¶
type ListOption func(*ListOptions)
ListOption option is used to list services
func ListContext ¶
func ListContext(ctx context.Context) ListOption
func ListDomain ¶
func ListDomain(d string) ListOption
type ListOptions ¶
type Node ¶
type Node struct { Id string `json:"id"` Address string `json:"address"` Metadata map[string]string `json:"metadata"` }
Node holds node registry info
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 ¶
func NewOptions() Options
type RegisterOption ¶
type RegisterOption func(*RegisterOptions)
RegisterOption option is used to register service
func RegisterContext ¶
func RegisterContext(ctx context.Context) RegisterOption
func RegisterDomain ¶
func RegisterDomain(d string) 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, ...}
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"` }
Service holds service registry info
type Value ¶
type Value struct { Name string `json:"name"` Type string `json:"type"` Values []*Value `json:"values"` }
Valud holds additional kv stuff
type WatchOption ¶
type WatchOption func(*WatchOptions)
WatchOption option is used to watch service changes
func WatchContext ¶
func WatchContext(ctx context.Context) WatchOption
func WatchDomain ¶
func WatchDomain(d string) WatchOption