Documentation
¶
Overview ¶
Package ha provides high availability support for Mandau, including multi-core connection management and automatic failover.
Index ¶
- type CoreNode
- func NewCoreNode(id, address string, priority int, tlsConfig transport.TLSConfig) *CoreNode
- func NewCoreNodeInsecure(id, address string, priority int) *CoreNode
- func NewCoreNodeInsecureWithCreds(id, address string, priority int) *CoreNode
- func NewCoreNodeWithTLS(id, address string, priority int, certPath, keyPath, caPath string) *CoreNode
- type FailoverConfig
- type FailoverManager
- func (fm *FailoverManager) AddNode(node *CoreNode)
- func (fm *FailoverManager) AddNodes(nodes []*CoreNode)
- func (fm *FailoverManager) Connect(ctx context.Context) error
- func (fm *FailoverManager) ConnectWithFailover(ctx context.Context) error
- func (fm *FailoverManager) Failover(ctx context.Context) error
- func (fm *FailoverManager) GetActiveConnection() *grpc.ClientConn
- func (fm *FailoverManager) GetActiveNode() *CoreNode
- func (fm *FailoverManager) GetNodeConnection(nodeID string) (*grpc.ClientConn, error)
- func (fm *FailoverManager) GetNodeState(nodeID string) (NodeState, error)
- func (fm *FailoverManager) ListNodes() []*CoreNode
- func (fm *FailoverManager) Stop()
- type NodeState
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 ¶
NewCoreNode creates a new core node with transport manager
func NewCoreNodeInsecure ¶
NewCoreNodeInsecure creates a new core node without TLS (for development)
func NewCoreNodeInsecureWithCreds ¶
NewCoreNodeInsecureWithCreds creates a new core node without TLS but with custom credentials
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