Documentation ¶
Index ¶
- func GenerateNodeID() string
- type Metrics
- type Node
- type NodeMetadata
- type NodeStatus
- type State
- func (s *State) AddLocalEndpoint(endpointID string)
- func (s *State) AddNode(node *Node)
- func (s *State) LocalEndpointListeners(endpointID string) int
- func (s *State) LocalID() string
- func (s *State) LocalNode() *Node
- func (s *State) LookupEndpoint(endpointID string) (*Node, bool)
- func (s *State) Metrics() *Metrics
- func (s *State) Node(id string) (*Node, bool)
- func (s *State) Nodes() []*Node
- func (s *State) NodesMetadata() []*NodeMetadata
- func (s *State) OnLocalEndpointUpdate(f func(endpointID string))
- func (s *State) OnRemoteEndpointUpdate(f func(nodeID string, endpointID string))
- func (s *State) RemoveLocalEndpoint(endpointID string)
- func (s *State) RemoveNode(id string) bool
- func (s *State) RemoveRemoteEndpoint(id string, endpointID string) bool
- func (s *State) UpdateRemoteEndpoint(id string, endpointID string, listeners int) bool
- func (s *State) UpdateRemoteStatus(id string, status NodeStatus) bool
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateNodeID ¶
func GenerateNodeID() string
Types ¶
type Metrics ¶
type Metrics struct { // Nodes contains the number of known nodes in the cluster, labelled by // status. Nodes *prometheus.GaugeVec }
func NewMetrics ¶
func NewMetrics() *Metrics
func (*Metrics) Register ¶
func (m *Metrics) Register(registry *prometheus.Registry)
type Node ¶
type Node struct { // ID is a unique identifier for the node in the cluster. // // The ID is immutable. ID string `json:"id"` // Status contains the known status of the node. Status NodeStatus `json:"status"` // ProxyAddr is the advertised proxy address. // // The address is immutable. ProxyAddr string `json:"proxy_addr"` // AdminAddr is the advertised admin address. // // The address is immutable. AdminAddr string `json:"admin_addr"` // Endpoints contains the known active endpoints on the node (endpoints // with at least one upstream listener). // // This maps the endpoint ID to the number of known listeners for that // endpoint. Endpoints map[string]int `json:"endpoints"` }
Node represents the known state about a node in the cluster.
Note to ensure updates are propagated, never update a node directly, only ever update via the NetworkMap.
func (*Node) Metadata ¶
func (n *Node) Metadata() *NodeMetadata
type NodeMetadata ¶
type NodeMetadata struct { ID string `json:"id"` Status NodeStatus `json:"status"` ProxyAddr string `json:"proxy_addr"` AdminAddr string `json:"admin_addr"` Endpoints int `json:"endpoints"` // Upstreams is the number of upstreams connected to this node. Upstreams int `json:"upstreams"` }
NodeMetadata contains metadata fields from Node.
type NodeStatus ¶
type NodeStatus string
NodeStatus contains the known status of a node.
const ( // NodeStatusActive means the node is healthy and accepting traffic. NodeStatusActive NodeStatus = "active" // NodeStatusUnreachable means the node is considered unreachable. NodeStatusUnreachable NodeStatus = "unreachable" // NodeStatusLeft means the node has left the cluster. NodeStatusLeft NodeStatus = "left" )
type State ¶
type State struct {
// contains filtered or unexported fields
}
State represents the known state of the cluster as seen by the local node.
This state is eventually consistent.
func (*State) AddLocalEndpoint ¶
AddLocalEndpoint adds the active endpoint to the local node state.
func (*State) LocalEndpointListeners ¶
func (*State) LookupEndpoint ¶
LookupEndpoint looks up a node that the endpoint with the given ID is active on.
func (*State) Node ¶
Node returns the known state of the node with the given ID, or false if the node is unknown.
func (*State) NodesMetadata ¶
func (s *State) NodesMetadata() []*NodeMetadata
NodesMetadata returns the metadata of the known nodes.
func (*State) OnLocalEndpointUpdate ¶
OnLocalEndpointUpdate subscribes to changes to the local nodes active endpoints.
The callback is called with the cluster mutex locked so must not block or call back to the cluster.
func (*State) OnRemoteEndpointUpdate ¶ added in v0.5.0
func (*State) RemoveLocalEndpoint ¶
RemoveLocalEndpoint removes the active endpoint from the local node state.
func (*State) RemoveNode ¶
RemoveNode removes the node with the given ID from the cluster.
func (*State) RemoveRemoteEndpoint ¶
RemoveRemoteEndpoint removes the active endpoint from the node with the given ID.
func (*State) UpdateRemoteEndpoint ¶
UpdateRemoteEndpoint sets the number of listeners for the active endpoint for the node with the given ID.
func (*State) UpdateRemoteStatus ¶
func (s *State) UpdateRemoteStatus(id string, status NodeStatus) bool
UpdateRemoteStatus sets the status of the remote node with the given ID.