operations

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: PostgreSQL Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NodeUpdateStrategyRolling will update nodes sequentially, meaning that
	// downtime is limited to a single node.
	NodeUpdateStrategyRolling = "rolling"
	// NodeUpdateStrategyConcurrent will update nodes simultaneously, which will
	// minimize runtime, but could result in database-wide downtime.
	NodeUpdateStrategyConcurrent = "concurrent"
)

Variables

This section is empty.

Functions

func AddNode

func AddNode(node *NodeResources) ([]*resource.State, error)

AddNode returns a sequence of diffs to add the given node, where each state only contains changed resources from the previous state. These states should be cumulatively merged with previous states to produce the sequence of desired states. This function always creates primary instances first and creates replica instances simultaneously.

func AddNodes

func AddNodes(new []*NodeResources) ([]*resource.State, error)

AddNodes returns a sequence of state diffs where each of the given nodes are added simultaneously. This function retains the primary-first order from AddNode, so primary instances are created simultaneously, followed by a single state for all replica instances.

func ConcurrentUpdateNodes

func ConcurrentUpdateNodes(nodes []*NodeResources) ([]*resource.State, error)

ConcurrentUpdateNodes returns a sequence of state diffs where each of the given nodes is updated simultaneously. This function retains the replica-first order from UpdateNode.

func EndState

func EndState(nodes []*NodeResources) (*resource.State, error)

EndState computes the end state for the database, containing only the given nodes.

func PopulateNode

func PopulateNode(node *NodeResources, existingNodeNames []string) (*resource.State, error)

PopulateNode returns a diff that adds resources to sync the given node with its source node.

func PopulateNodes

func PopulateNodes(existing, new []*NodeResources) (*resource.State, error)

PopulateNodes returns a diff that adds resources to sync the given nodes with their source nodes. The syncs are performed simultaneously.

func RestoreDatabase

func RestoreDatabase(
	start *resource.State,
	nodes []*NodeResources,
	targets []*NodeRestoreResources,
) ([]resource.Plan, error)

RestoreDatabase returns a sequence of plans that will restore a database using the restore resources for each target node. Note that the `nodes` argument should only contain nodes that are _not_ being restored, and `targets` should only contain nodes that _are_ being restored. In other words, they should be disjoint with each other.

func RestoreNode

func RestoreNode(node *NodeRestoreResources) ([]*resource.State, error)

RestoreNode returns a sequence of states that restore the given node. Unlike some of the other functions in this package, these states are not diffs, and each state should be merged onto the same base state. This is necessary to facilitate deletes during the process, such as deleting the node and instance resources before running the restore. See RestoreDatabase for how these states are used.

func RollingUpdateNodes

func RollingUpdateNodes(nodes []*NodeResources) ([]*resource.State, error)

RollingUpdateNodes returns a sequence of state diffs where each of the given nodes is updated in-order sequentially. This function retains the replica-first order from UpdateNode.

func UpdateDatabase

func UpdateDatabase(
	options UpdateDatabaseOptions,
	start *resource.State,
	nodes []*NodeResources,
) ([]resource.Plan, error)

UpdateDatabase returns a sequence of plans that will update a database to match the nodes in the `nodes` argument. The plans always use the same order: - Update existing nodes - Add new nodes - Populate new nodes - Delete nodes and other extraneous resources

func UpdateNode

func UpdateNode(node *NodeResources) ([]*resource.State, error)

UpdateNode returns a sequence of diffs to update the given node, where each state only contains changed resources from the previous state. These states should be cumulatively merged with previous states to produce the sequence of desired states. This function always updates the node's replica instances.

Types

type NodeResources

type NodeResources struct {
	NodeName          string
	SourceNode        string
	PrimaryInstanceID string
	InstanceResources []*database.InstanceResources
	RestoreConfig     *database.RestoreConfig
}

type NodeRestoreResources

type NodeRestoreResources struct {
	NodeName         string
	PrimaryInstance  *database.InstanceResources
	RestoreInstance  *database.InstanceResources
	ReplicaInstances []*database.InstanceResources
}

NodeRestoreResources contains the restore resources for the primary instance as well as the end state for both the primary instance and the replica instances for the given node.

func (*NodeRestoreResources) ToNodeResources

func (n *NodeRestoreResources) ToNodeResources() *NodeResources

type NodeUpdateStrategy

type NodeUpdateStrategy string

NodeUpdateStrategy determines the order that nodes are updated within a database.

type UpdateDatabaseOptions

type UpdateDatabaseOptions struct {
	NodeUpdateStrategy NodeUpdateStrategy
	PlanOptions        resource.PlanOptions
}

Jump to

Keyboard shortcuts

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