archiver

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package archiver manages the WAL archiving process

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WALArchiver

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

WALArchiver is a structure containing every info need to archive a set of WAL files using pgbackrest archive-push

func New

func New(
	ctx context.Context,
	env []string,
	spoolDirectory string,
	pgDataDirectory string,
	emptyWalArchivePath string,
) (archiver *WALArchiver, err error)

New creates a new WAL archiver

func (*WALArchiver) ArchiveList

func (archiver *WALArchiver) ArchiveList(
	ctx context.Context,
	walNames []string,
	options []string,
) (result []WALArchiverResult)

ArchiveList archives a list of WAL files in parallel

func (*WALArchiver) CheckWalArchiveDestination

func (archiver *WALArchiver) CheckWalArchiveDestination(
	ctx context.Context,
	configuration *pgbackrestApi.PgbackrestConfiguration,
	stanza string,
	env []string,
) error

CheckWalArchiveDestination checks if the destination archive is ready to perform archiving, i.e. if proper stanzas exist.

func (*WALArchiver) DeleteFromSpool

func (archiver *WALArchiver) DeleteFromSpool(
	walName string,
) (hasBeenDeleted bool, err error)

DeleteFromSpool checks if a WAL file is in the spool and, if it is, remove it

func (*WALArchiver) GatherWALFilesToArchive

func (archiver *WALArchiver) GatherWALFilesToArchive(
	ctx context.Context,
	requestedWALFile string,
	parallel int,
) (walList []string)

GatherWALFilesToArchive reads from the archived status the list of WAL files that can be archived in parallel way. `requestedWALFile` is the name of the file whose archiving was requested by PostgreSQL, and that file is always the first of the list and is always included. `parallel` is the maximum number of WALs that we can archive in parallel

func (*WALArchiver) PgbackrestCheckWalArchiveOptions

func (archiver *WALArchiver) PgbackrestCheckWalArchiveOptions(
	ctx context.Context,
	configuration *pgbackrestApi.PgbackrestConfiguration,
	clusterName string,
) ([]string, error)

PgbackrestCheckWalArchiveOptions create the options needed for the `pgbackrest check` command.

func (*WALArchiver) PgbackrestWalArchiveOptions

func (archiver *WALArchiver) PgbackrestWalArchiveOptions(
	ctx context.Context,
	configuration *pgbackrestApi.PgbackrestConfiguration,
	clusterName string,
) (options []string, err error)

PgbackrestWalArchiveOptions calculates the set of options to be used with pgbackrest archive-push

type WALArchiverResult

type WALArchiverResult struct {
	// The WAL that have been archived
	WalName string

	// If not nil, this is the error that has been detected
	Err error

	// The time when we started pgbackrest archive-push
	StartTime time.Time

	// The time when pgbackrest archive-push ended
	EndTime time.Time
}

WALArchiverResult contains the result of the archival of one WAL

Jump to

Keyboard shortcuts

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