membership

package
v0.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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

View Source
var ErrListenerAlreadyExist = errors.New("Listener already exist for the service")

ErrListenerAlreadyExist is thrown on a duplicate AddListener call from the same listener

View Source
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

func (*HostInfo) Label

func (hi *HostInfo) Label(key string) (value string, has bool)

Label implements ringpop's Membership interface

func (*HostInfo) SetLabel

func (hi *HostInfo) SetLabel(key string, value string)

SetLabel sets the label.

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 bark.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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL