Documentation
¶
Overview ¶
Package archiver manages the WAL archiving process
Index ¶
- Variables
- type WALArchiver
- func (archiver *WALArchiver) ArchiveList(ctx context.Context, walNames []string, options []string) (result []WALArchiverResult)
- func (archiver *WALArchiver) CheckWalArchiveDestination(ctx context.Context, configuration *pgbackrestApi.PgbackrestConfiguration, ...) error
- func (archiver *WALArchiver) DeleteFromSpool(walName string) (hasBeenDeleted bool, err error)
- func (archiver *WALArchiver) GatherWALFilesToArchive(ctx context.Context, requestedWALFile string, parallel int) (walList []string)
- func (archiver *WALArchiver) PgbackrestCheckWalArchiveOptions(ctx context.Context, configuration *pgbackrestApi.PgbackrestConfiguration, ...) ([]string, error)
- func (archiver *WALArchiver) PgbackrestWalArchiveOptions(ctx context.Context, configuration *pgbackrestApi.PgbackrestConfiguration, ...) (options []string, err error)
- type WALArchiverResult
Constants ¶
This section is empty.
Variables ¶
var ErrStanzaMissing = errors.New("pgbackrest stanza has not been created")
ErrStanzaMissing is returned by CheckWalArchiveDestination when the destination repository is reachable but the pgBackRest stanza has not been created yet. Callers can react to it (create the stanza, or treat the destination as empty) instead of inspecting the "pgbackrest info" output themselves.
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 that the destination archive is reachable and its stanza exists. It runs "pgbackrest info" (which, unlike stanza-create, does not take the stanza lock) and returns ErrStanzaMissing when the repository is reachable but the stanza has not been created yet.
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 It's important to ensure this method returns absolute paths. While pgbackrest can work with relative ones, such setup requires additional config flags and a matching Postgresql working directory configuration, which seems to be invalid in the context of the plugin's container.
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