clustering

package
v0.0.0-...-16cb735 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterGobNames

func RegisterGobNames()

RegisterGobNames regiters all the necessary interfaces used by the clustering package

Types

type Broadcast

type Broadcast struct {
	Envelope *Envelope
}

Broadcast is a message that may be broadcast across the cluster

func (*Broadcast) Finished

func (broadcast *Broadcast) Finished()

func (*Broadcast) Invalidates

func (broadcast *Broadcast) Invalidates(other memberlist.Broadcast) bool

func (*Broadcast) Message

func (broadcast *Broadcast) Message() []byte

type Cluster

type Cluster struct {
	Memberlist *memberlist.Memberlist
	// Members are all welcomed members of the cluster from this node's point of view
	Members map[string]*ClusterMember
	// ServiceUpdates published the configuration any time it's updated
	ServicesUpdates chan []*configuration.ServiceConfiguration
	// Store is a state store for the cluster
	Store *storage.Store
	// contains filtered or unexported fields
}

Cluster is a cluster of monitoring nodes

func NewCluster

func NewCluster(config *configuration.Configuration) (*Cluster, error)

NewCluster creates a new cluster based on the given configuration

func (*Cluster) BroadcastStatusUpdate

func (cluster *Cluster) BroadcastStatusUpdate(origin string, serviceId string, monitorId string, status monitoring.Status) error

BroadcastStatusUpdate broadcasts an update for a specified monitor over an eventual consistent channel

func (*Cluster) Join

func (cluster *Cluster) Join(peers []string) error

Join joins one or more peers using the given addresses

func (*Cluster) Services

func (cluster *Cluster) Services() []*configuration.ServiceConfiguration

Services specifies the combined monitored services of the cluster

func (*Cluster) Status

func (cluster *Cluster) Status() ClusterStatus

type ClusterMember

type ClusterMember struct {
	// ServicesVersion is the current (incremental) version of the configured services
	ServicesVersion int
	// Services are the services configured for the cluster member
	Services []*configuration.ServiceConfiguration
}

ClusterMember is a member of a cluster

type ClusterStatus

type ClusterStatus int
const (
	ClusterStatusHealthy ClusterStatus = iota
	ClusterStatusUnhealthy
)

func (ClusterStatus) String

func (i ClusterStatus) String() string

type ConfigUpdateMessage

type ConfigUpdateMessage struct {
	// Version is the incremental version of the configuration
	Version int
	// Node is the node for which this configuration is for
	Node     string
	Services []*configuration.ServiceConfiguration
}

ConfigUpdateMessage is sent from a node whenever there is a configuration update

func (*ConfigUpdateMessage) Invalidates

func (message *ConfigUpdateMessage) Invalidates(other Message) bool

type Envelope

type Envelope struct {
	// Sender is the node from which the message was sent
	Sender      string
	MessageType MessageType
	Message     Message
}

Envelope contains a message to be sent across a cluster

func (*Envelope) Bytes

func (envelope *Envelope) Bytes() []byte

RegisterGobNames must be called before

type Message

type Message interface {
	// Invalidates specifies whether the message invalidates the other message
	Invalidates(other Message) bool
}

Message is a message that may be sent across a cluster

type MessageType

type MessageType int
const (
	ConfigUpdate MessageType = iota
	StatusUpdate
)

type StatusUpdateMessage

type StatusUpdateMessage struct {
	// Timestamp is the Unix timestamp of when the update occured
	Timestamp int64
	// Node is the node observing the status change
	Node string
	// Origin is the node which requested the monitoring
	Origin string
	// ServiceId is the id of the service which received an update
	ServiceId string
	// MonitorId is the id of the monitor which received an update
	MonitorId string
	// Status is the observed status
	Status monitoring.Status
}

StatusUpdateMessage is broadcast from a node whenever there is a status change from a service

func (*StatusUpdateMessage) Invalidates

func (message *StatusUpdateMessage) Invalidates(other Message) bool

Jump to

Keyboard shortcuts

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