Documentation ¶
Overview ¶
Package registry is a component for service discovery
Index ¶
- Constants
- Variables
- func NewConfig(plugin string) (any, error)
- type Config
- type ConfigImpl
- 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 Result
- type Service
- type Value
- type WatchOption
- type WatchOptions
- type Watcher
Constants ¶
View Source
const Name = "registry"
Variables ¶
View Source
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") )
View Source
var DiSet = wire.NewSet(ProvideFlags, ProvideConfig, Provide)
View Source
var Plugins = container.NewPlugins( func() Registry { return nil }, func() any { return nil }, )
Functions ¶
Types ¶
type Config ¶
type Config interface { config.ConfigPlugin // Optional GetLogger() *log.ConfigImpl GetAddresses() []string // Timeout in milliseconds. GetTimeout() int }
type ConfigImpl ¶
type ConfigImpl struct { *config.ConfigPluginImpl Logger *log.ConfigImpl Addresses []string Timeout int }
func NewComponentConfig ¶
func NewComponentConfig() *ConfigImpl
func (*ConfigImpl) GetAddresses ¶
func (c *ConfigImpl) GetAddresses() []string
func (*ConfigImpl) GetLogger ¶
func (c *ConfigImpl) GetLogger() *log.ConfigImpl
func (*ConfigImpl) GetTimeout ¶
func (c *ConfigImpl) GetTimeout() int
func (*ConfigImpl) Merge ¶
func (c *ConfigImpl) Merge(aPreviousConfig any) error
MergePrevious merges the previous config into this one.
type DeregisterOption ¶
type DeregisterOption func(*DeregisterOptions)
func DeregisterContext ¶
func DeregisterContext(ctx context.Context) DeregisterOption
type DeregisterOptions ¶
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 Options ¶
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(aConfig any, opts ...Option) error Config() any 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 WatchOption ¶
type WatchOption func(*WatchOptions)
func WatchContext ¶
func WatchContext(ctx context.Context) WatchOption
type WatchOptions ¶
Click to show internal directories.
Click to hide internal directories.