clustering

package
v0.0.0-...-8ca999e Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broadcaster

type Broadcaster interface {
	// BroadcastAlerts broadcasts a group of alerts to a cluster.
	BroadcastAlerts(ctx context.Context, alerts ...model.Alert) error

	// BroadcastAlertAcknowledgement broadcasts an AlertAcknowledgement of the given alert.
	BroadcastAlertAcknowledgement(ctx context.Context, alertID string, ack model.AlertAcknowledgement) error

	// BroadcastSilences broadcasts a group of silences to a cluster.
	BroadcastSilences(ctx context.Context, silences ...model.Silence) error
}

Broadcaster defines something that can tell other things about data.

type Clusterer

type Clusterer interface {
	// IsAuthoritativeFor returns true if this is the node that should send notifications for the given alert.
	IsAuthoritativeFor(ctx context.Context, a *model.Alert) bool

	// Nodes returns a list of the nodes in the cluster.
	Nodes() []any
}

Clusterer is used to determine if this node is authoritative (and thus should send a notification for) a given alert.

type ClustererDelegate

type ClustererDelegate interface {
	// AddNode is called when a node is added to the cluster.
	AddNode(name, address string)

	// RemoveNode is called when a node is removed, or fails.
	RemoveNode(name string)
}

ClustererDelegates receive cluster updates (node additions and removals).

type EventDelegate

type EventDelegate interface {
	// ProcessAlert is called when a new alert comes in. There are no guarantees that this alert isn't one
	// we haven't seen before - it might be an update on status etc.
	ProcessAlert(ctx context.Context, alert model.Alert)

	// ProcessAlertAcknowledgement is called when a new alert acknowledgement comes in.
	ProcessAlertAcknowledgement(ctx context.Context, alertID string, ack model.AlertAcknowledgement)

	// ProcessSilence is called when a new silence comes in. There are no guarantees that this silence isn't one
	// we haven't seen before - it might be an update on status etc.
	ProcessSilence(ctx context.Context, silence model.Silence)
}

EventDelegate provides a delegate that can handle events as they come in from a cluster channel.

type RingClusterer

type RingClusterer struct {
	// contains filtered or unexported fields
}

RingClusterer is a clusterer that keeps track of nodes in a consistent hash ring.

func NewRingClusterer

func NewRingClusterer(myName, myAddress string) *RingClusterer

NewRingClusterer constructs a new RingClusterer, with the given name and address. This name and address _must_ be the same as the node in the underlying Cluster in order to properly shard alerts.

func (*RingClusterer) AddNode

func (r *RingClusterer) AddNode(name, address string)

func (*RingClusterer) GetAuthoritativeNode

func (r *RingClusterer) GetAuthoritativeNode(ctx context.Context, a *model.Alert) consistent.Member

GetAuthoritativeNode returns the node that is authoritative for the given alert.

func (*RingClusterer) IsAuthoritativeFor

func (r *RingClusterer) IsAuthoritativeFor(ctx context.Context, a *model.Alert) bool

func (*RingClusterer) Nodes

func (r *RingClusterer) Nodes() []any

func (*RingClusterer) RemoveNode

func (r *RingClusterer) RemoveNode(name string)

func (*RingClusterer) SetShardLabels

func (r *RingClusterer) SetShardLabels(keys []string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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