topology

package
v0.0.0-...-61fb0be Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	ClusterEndpoint ProbeableEndpoint
	NodeEndpoints   map[string]ProbeableEndpoint
}

func NewCluster

func NewCluster(cluster ProbeableEndpoint) Cluster

func (*Cluster) AddEndpoint

func (c *Cluster) AddEndpoint(endpoint ProbeableEndpoint)

type ClusterMap

type ClusterMap struct {
	Clusters map[string]Cluster
}

func NewClusterMap

func NewClusterMap() ClusterMap

func (*ClusterMap) AppendCluster

func (cm *ClusterMap) AppendCluster(cluster Cluster)

func (*ClusterMap) Diff

func (oldMap *ClusterMap) Diff(newMap *ClusterMap) (oldEndpoints []ProbeableEndpoint, newEndpoints []ProbeableEndpoint)

Diff make the intersection between two clusters and return: oldEndpoints: the endpoints that were present in the old cluster map but not in the new one newEndpoints: the endpoints that are present in the new cluster map but not in the old one

type DummyEndpoint

type DummyEndpoint struct {
	Name    string
	Hash    string
	Cluster bool
}

DummyEndpoint is a fake ProbeableEndpoint that don't do anything Useful for testing

func (DummyEndpoint) Close

func (d DummyEndpoint) Close() error

func (DummyEndpoint) Connect

func (d DummyEndpoint) Connect() error

func (DummyEndpoint) GetHash

func (d DummyEndpoint) GetHash() string

func (DummyEndpoint) GetName

func (d DummyEndpoint) GetName() string

func (DummyEndpoint) IsCluster

func (d DummyEndpoint) IsCluster() bool

func (DummyEndpoint) Refresh

func (d DummyEndpoint) Refresh() error

type ProbeableEndpoint

type ProbeableEndpoint interface {
	// Hash used to compare two endpoints (useful for topology updates)
	GetHash() string
	// Name of the endpoint useful for metrics and loggings
	GetName() string
	// IsCluster return true if the endpoint is cluster endpoint, false if node
	IsCluster() bool
	// Connect is called to initialize connections to the remote database
	Connect() error
	// Refresh is called to refresh the states of the endpoint
	// Can be used to check for new tables/namespaces/nodes
	Refresh() error
	// Close should terminate all connections to the remote database
	Close() error
}

ProbeableEndpoint represent an endpoint that can be checked by the probe

Jump to

Keyboard shortcuts

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