Documentation
¶
Index ¶
Constants ¶
const (
// RoleKey label is set by every single service as soon as it bootstraps its
// ringpop instance. The data for this key is the service name
RoleKey = "serviceName"
)
Variables ¶
var ErrInsufficientHosts = &shared.InternalServiceError{Message: "Not enough hosts to serve the request"}
ErrInsufficientHosts is thrown when there are not enough hosts to serve the request
var ErrListenerAlreadyExist = errors.New("Listener already exist for the service")
ErrListenerAlreadyExist is thrown on a duplicate AddListener call from the same listener
var ErrUnknownService = errors.New("Service not tracked by Monitor")
ErrUnknownService is thrown for a service that is not tracked by this instance
Functions ¶
This section is empty.
Types ¶
type ChangedEvent ¶
type ChangedEvent struct {
HostsAdded []*HostInfo
HostsUpdated []*HostInfo
HostsRemoved []*HostInfo
}
ChangedEvent describes a change in membership
type HostInfo ¶
type HostInfo struct {
// contains filtered or unexported fields
}
HostInfo is a type that contains the info about a cadence host
func NewHostInfo ¶
func NewHostInfo(addr string, labels map[string]string) *HostInfo
NewHostInfo creates a new HostInfo instance
func (*HostInfo) GetAddress ¶
func (hi *HostInfo) GetAddress() string
GetAddress returns the ip:port address
func (*HostInfo) Identity ¶
func (hi *HostInfo) Identity() string
Identity implements ringpop's Membership interface
type Monitor ¶
type Monitor interface {
Start() error
Stop()
WhoAmI() (*HostInfo, error)
Lookup(service string, key string) (*HostInfo, error)
GetResolver(service string) (ServiceResolver, error)
// AddListener adds a listener for this service.
// The listener will get notified on the given
// channel, whenever there is a membership change.
// @service: The service to be listened on
// @name: The name for identifying the listener
// @notifyChannel: The channel on which the caller receives notifications
AddListener(service string, name string, notifyChannel chan<- *ChangedEvent) error
// RemoveListener removes a listener for this service.
RemoveListener(service string, name string) error
}
Monitor provides membership information for all cadence services. It can be used to query which member host of a service is responsible for serving a given key.
func NewRingpopMonitor ¶
func NewRingpopMonitor(services []string, rp *ringpop.Ringpop, logger log.Logger) Monitor
NewRingpopMonitor returns a ringpop-based membership monitor
type ServiceResolver ¶
type ServiceResolver interface {
Lookup(key string) (*HostInfo, error)
// AddListener adds a listener which will get notified on the given
// channel, whenever membership changes.
// @name: The name for identifying the listener
// @notifyChannel: The channel on which the caller receives notifications
AddListener(name string, notifyChannel chan<- *ChangedEvent) error
// RemoveListener removes a listener for this service.
RemoveListener(name string) error
}
ServiceResolver provides membership information for a specific cadence service. It can be used to resolve which member host is responsible for serving a given key.