Documentation
¶
Overview ¶
Package db provides database connection and management for PostgreSQL nodes.
Index ¶
- type DBManager
- func (m *DBManager) ApplySchema(ctx context.Context, node *schema.Node, schemaSQL string) error
- func (m *DBManager) ApplySchemaFromFile(ctx context.Context, node *schema.Node, filePath string) error
- func (m *DBManager) ApplySchemaFromFileToAll(ctx context.Context, filePath string) map[string]error
- func (m *DBManager) ApplySchemaToAll(ctx context.Context, schemaSQL string) map[string]error
- func (m *DBManager) CheckReplicationHealth(ctx context.Context) (healthy bool, issues []string)
- func (m *DBManager) Close()
- func (m *DBManager) Connect(ctx context.Context, node *schema.Node) (*pgxpool.Pool, error)
- func (m *DBManager) CreatePublication(ctx context.Context, node *schema.Node) error
- func (m *DBManager) CreateReplicationSlot(ctx context.Context, publisherNode *schema.Node, slotName string) error
- func (m *DBManager) CreateSubscription(ctx context.Context, subscriberNode, publisherNode *schema.Node) error
- func (m *DBManager) GetAllNodeStatuses(ctx context.Context) []NodeStatus
- func (m *DBManager) GetNode(name string) *schema.Node
- func (m *DBManager) GetNodeStatus(ctx context.Context, node *schema.Node) NodeStatus
- func (m *DBManager) GetNodes() []schema.Node
- func (m *DBManager) GetPool(ctx context.Context, nodeName string) (*pgxpool.Pool, error)
- func (m *DBManager) Ping(ctx context.Context, nodeName string) error
- func (m *DBManager) SetupBidirectionalReplication(ctx context.Context) []ReplicationResult
- func (m *DBManager) SetupReplicationForNode(ctx context.Context, nodeName string) []ReplicationResult
- type NodeStatus
- type PublicationInfo
- type ReplicationResult
- type ReplicationSlotInfo
- type SubscriptionInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBManager ¶
type DBManager struct {
// contains filtered or unexported fields
}
DBManager manages database connections to multiple PostgreSQL nodes.
func NewDBManager ¶
NewDBManager creates a new DBManager with the given nodes.
func (*DBManager) ApplySchema ¶
ApplySchema applies SQL schema to a node within a transaction. It also configures the pgconverge.node_name GUC so HLC triggers know which node they are running on.
func (*DBManager) ApplySchemaFromFile ¶
func (m *DBManager) ApplySchemaFromFile(ctx context.Context, node *schema.Node, filePath string) error
ApplySchemaFromFile applies schema from a file to a node.
func (*DBManager) ApplySchemaFromFileToAll ¶
ApplySchemaFromFileToAll applies schema from a file to all nodes.
func (*DBManager) ApplySchemaToAll ¶
ApplySchemaToAll applies SQL schema to all nodes.
func (*DBManager) CheckReplicationHealth ¶
CheckReplicationHealth checks the health of replication across all nodes.
func (*DBManager) CreatePublication ¶
CreatePublication creates a publication on a node.
func (*DBManager) CreateReplicationSlot ¶
func (m *DBManager) CreateReplicationSlot(ctx context.Context, publisherNode *schema.Node, slotName string) error
CreateReplicationSlot creates a replication slot on a publisher node.
func (*DBManager) CreateSubscription ¶
func (m *DBManager) CreateSubscription(ctx context.Context, subscriberNode, publisherNode *schema.Node) error
CreateSubscription creates a subscription from subscriber to publisher.
func (*DBManager) GetAllNodeStatuses ¶
func (m *DBManager) GetAllNodeStatuses(ctx context.Context) []NodeStatus
GetAllNodeStatuses returns the status of all nodes.
func (*DBManager) GetNodeStatus ¶
GetNodeStatus returns the status of a specific node.
func (*DBManager) SetupBidirectionalReplication ¶
func (m *DBManager) SetupBidirectionalReplication(ctx context.Context) []ReplicationResult
SetupBidirectionalReplication sets up bidirectional replication between all nodes.
func (*DBManager) SetupReplicationForNode ¶
func (m *DBManager) SetupReplicationForNode(ctx context.Context, nodeName string) []ReplicationResult
SetupReplicationForNode sets up replication for a specific node.
type NodeStatus ¶
type NodeStatus struct {
Name string
Host string
Port int
External bool
Reachable bool
Error error
Warnings []string
Version string
WalLevel string
Publications []PublicationInfo
Subscriptions []SubscriptionInfo
ReplicationSlots []ReplicationSlotInfo
}
NodeStatus represents the status of a PostgreSQL node.
type PublicationInfo ¶
PublicationInfo represents a PostgreSQL publication.
type ReplicationResult ¶
ReplicationResult represents the result of a replication operation.
type ReplicationSlotInfo ¶
ReplicationSlotInfo represents a PostgreSQL replication slot.
type SubscriptionInfo ¶
SubscriptionInfo represents a PostgreSQL subscription.