ha

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package ha provides high availability support for Mandau, including multi-core connection management and automatic failover.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CoreNode

type CoreNode struct {
	ID       string
	Address  string
	Priority int
	Active   *transport.Manager
	State    NodeState
	// contains filtered or unexported fields
}

CoreNode represents a Mandau Core server instance

func NewCoreNode

func NewCoreNode(id, address string, priority int, tlsConfig transport.TLSConfig) *CoreNode

NewCoreNode creates a new core node with transport manager

func NewCoreNodeInsecure

func NewCoreNodeInsecure(id, address string, priority int) *CoreNode

NewCoreNodeInsecure creates a new core node without TLS (for development)

func NewCoreNodeInsecureWithCreds

func NewCoreNodeInsecureWithCreds(id, address string, priority int) *CoreNode

NewCoreNodeInsecureWithCreds creates a new core node without TLS but with custom credentials

func NewCoreNodeWithTLS

func NewCoreNodeWithTLS(id, address string, priority int, certPath, keyPath, caPath string) *CoreNode

NewCoreNodeWithTLS creates a new core node with mTLS configuration

type FailoverConfig

type FailoverConfig struct {
	// HealthCheckInterval is how often to check node health
	HealthCheckInterval time.Duration
	// HealthCheckTimeout is the timeout for health check requests
	HealthCheckTimeout time.Duration
	// FailoverThreshold is the number of failed health checks before failover
	FailoverThreshold int
	// MaxRetries is the maximum number of reconnection attempts
	MaxRetries int
	// RetryDelay is the base delay between retry attempts
	RetryDelay time.Duration
}

FailoverConfig holds configuration for failover management

type FailoverManager

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

FailoverManager manages connections to multiple core nodes

func NewFailoverManager

func NewFailoverManager(config FailoverConfig) *FailoverManager

NewFailoverManager creates a new failover manager

func (*FailoverManager) AddNode

func (fm *FailoverManager) AddNode(node *CoreNode)

AddNode adds a core node to the failover pool

func (*FailoverManager) AddNodes

func (fm *FailoverManager) AddNodes(nodes []*CoreNode)

AddNodes adds multiple core nodes

func (*FailoverManager) Connect

func (fm *FailoverManager) Connect(ctx context.Context) error

Connect attempts to connect to the highest priority available node

func (*FailoverManager) ConnectWithFailover

func (fm *FailoverManager) ConnectWithFailover(ctx context.Context) error

ConnectWithFailover attempts to connect with automatic failover on failure

func (*FailoverManager) Failover

func (fm *FailoverManager) Failover(ctx context.Context) error

Failover switches to the next available node

func (*FailoverManager) GetActiveConnection

func (fm *FailoverManager) GetActiveConnection() *grpc.ClientConn

GetActiveConnection returns the currently active gRPC connection

func (*FailoverManager) GetActiveNode

func (fm *FailoverManager) GetActiveNode() *CoreNode

GetActiveNode returns the currently active core node

func (*FailoverManager) GetNodeConnection

func (fm *FailoverManager) GetNodeConnection(nodeID string) (*grpc.ClientConn, error)

GetNodeConnection returns a gRPC connection to the specified node

func (*FailoverManager) GetNodeState

func (fm *FailoverManager) GetNodeState(nodeID string) (NodeState, error)

GetNodeState returns the state of a specific node

func (*FailoverManager) ListNodes

func (fm *FailoverManager) ListNodes() []*CoreNode

ListNodes returns all known core nodes

func (*FailoverManager) Stop

func (fm *FailoverManager) Stop()

Stop stops the failover manager

type NodeState

type NodeState string

NodeState represents the state of a core node

const (
	NodeStateActive      NodeState = "active"
	NodeStateStandby     NodeState = "standby"
	NodeStateUnreachable NodeState = "unreachable"
)

Jump to

Keyboard shortcuts

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