topology

package
v1.26.3 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// prevents excess goroutine creating while penalizing overloaded host
	DefaultPenaltySize     = 5
	DefaultMaxSize         = 300
	DefaultPenaltyDuration = time.Second * 10
)

Variables

View Source
var (
	HostHealth    *prometheus.GaugeVec
	HostPenalties *prometheus.CounterVec
)

Functions

func RegisterMetrics

func RegisterMetrics(cfg *config.Config)

Types

type Node

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

func NewNode

func NewNode(addr *url.URL, hb heartbeat.HeartBeat, clusterName, replicaName string, opts ...NodeOption) *Node

func (*Node) CurrentConnections

func (n *Node) CurrentConnections() uint32

func (*Node) CurrentLoad

func (n *Node) CurrentLoad() uint32

CurrentLoad returns the current node returns the number of open connections plus the penalty.

func (*Node) CurrentPenalty

func (n *Node) CurrentPenalty() uint32

func (*Node) DecrementConnections

func (n *Node) DecrementConnections()

func (*Node) Host

func (n *Node) Host() string

func (*Node) IncrementConnections

func (n *Node) IncrementConnections()

func (*Node) IsActive

func (n *Node) IsActive() bool

func (*Node) Penalize

func (n *Node) Penalize()

Penalize a node if a request failed to decrease it's priority. If the penalty is already at the maximum allowed size this function will not penalize the node further. A function will be registered to run after the penalty duration to increase the priority again.

func (*Node) ReplicaName

func (n *Node) ReplicaName() string

func (*Node) Scheme

func (n *Node) Scheme() string

func (*Node) SetIsActive

func (n *Node) SetIsActive(active bool)

func (*Node) StartHeartbeat

func (n *Node) StartHeartbeat(done <-chan struct{})

StartHeartbeat runs the heartbeat healthcheck against the node until the done channel is closed. If the heartbeat fails, the active status of the node is changed.

func (*Node) String

func (n *Node) String() string

type NodeOption

type NodeOption interface {
	// contains filtered or unexported methods
}

func WithDefaultActiveState

func WithDefaultActiveState(active bool) NodeOption

Jump to

Keyboard shortcuts

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