client

package
v1.24.3 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: Apache-2.0 Imports: 27 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package client contains a set of helper structures for CNPG to use the plugins exposing the CNPI interface

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPluginNotLoaded is raised when the plugin that should manage the backup
	// have not been loaded inside the cluster
	ErrPluginNotLoaded = errors.New("plugin not loaded")

	// ErrPluginNotSupportBackup is raised when the plugin that should manage the backup
	// doesn't support the Backup service
	ErrPluginNotSupportBackup = errors.New("plugin does not support Backup service")

	// ErrPluginNotSupportBackupEndpoint is raised when the plugin that should manage the backup
	// doesn't support the Backup RPC endpoint
	ErrPluginNotSupportBackupEndpoint = errors.New("plugin does not support the Backup RPC call")
)

Functions

This section is empty.

Types

type BackupCapabilities

type BackupCapabilities interface {
	// Backup takes a backup via a cnpg-i plugin
	Backup(
		ctx context.Context,
		cluster client.Object,
		backupObject client.Object,
		pluginName string,
		parameters map[string]string,
	) (*BackupResponse, error)
}

BackupCapabilities describes a set of behaviour needed to backup a PostgreSQL cluster

type BackupResponse

type BackupResponse struct {
	// This field contains a machine-readable ID of the
	// backup that is being taken
	BackupID string

	// This field contains a human-readable name of the
	// backup that is being taken
	BackupName string

	// This field contains the timestamp of the start
	// time of the backup
	StartedAt time.Time

	// This field contains the Unix timestamp of the end
	// time of the backup
	StoppedAt time.Time

	// This field contains the current WAL when the backup was started
	BeginWal string

	// This field contains the current WAL at the end of the backup
	EndWal string

	// This field contains the current LSN record when the backup was started
	BeginLsn string

	// This field contains the current LSN record when the backup has finished
	EndLsn string

	// This field contains the backup label of the backup that have been taken
	BackupLabelFile []byte

	// This field contains the tablespace map of the backup that have been taken
	TablespaceMapFile []byte

	// This field contains the ID of the instance that have been backed up
	InstanceID string

	// This field is set to true for online/hot backups and to false otherwise.
	Online bool
}

BackupResponse is the status of a newly created backup. This is used as a return type for the Backup RPC Call

type Client

Client describes a set of behaviour needed to properly handle all the plugin client expected features

func WithPlugins added in v1.24.0

func WithPlugins(ctx context.Context, repository repository.Interface, names ...string) (Client, error)

WithPlugins creates a new CNPG-I client for plugins in a certain repository, loading the plugins with the specified name

type ClusterCapabilities

type ClusterCapabilities interface {
	// MutateCluster calls the loaded plugisn to help to enhance
	// a cluster definition
	MutateCluster(
		ctx context.Context,
		object client.Object,
		mutatedObject client.Object,
	) error

	// ValidateClusterCreate calls all the loaded plugin to check if a cluster definition
	// is correct
	ValidateClusterCreate(
		ctx context.Context,
		object client.Object,
	) (field.ErrorList, error)

	// ValidateClusterUpdate calls all the loaded plugin to check if a cluster can
	// be changed from a value to another
	ValidateClusterUpdate(
		ctx context.Context,
		cluster client.Object,
		mutatedCluster client.Object,
	) (field.ErrorList, error)

	// SetStatusInCluster returns a map of [pluginName]: statuses to be assigned to the cluster
	SetStatusInCluster(ctx context.Context, cluster client.Object) (map[string]string, error)
}

ClusterCapabilities describes a set of behaviour needed to implement the Cluster capabilities

type ClusterReconcilerHooks

type ClusterReconcilerHooks interface {
	// PreReconcile is executed after we get the resources and update the status
	PreReconcile(
		ctx context.Context,
		cluster client.Object,
		object client.Object,
	) ReconcilerHookResult

	// PostReconcile is executed at the end of the reconciliation loop
	PostReconcile(
		ctx context.Context,
		cluster client.Object,
		object client.Object,
	) ReconcilerHookResult
}

ClusterReconcilerHooks decsribes a set of behavior needed to enhance the login of the Cluster reconcicliation loop

type Connection

type Connection interface {
	// Close closes the connection to every loaded plugin
	Close(ctx context.Context)

	// MetadataList exposes the metadata of the loaded plugins
	MetadataList() []connection.Metadata
}

Connection describes a set of behaviour needed to properly handle the plugin connections

type LifecycleCapabilities

type LifecycleCapabilities interface {
	// LifecycleHook notifies the registered plugins of a given event for a given object
	LifecycleHook(
		ctx context.Context,
		operationVerb plugin.OperationVerb,
		cluster client.Object,
		object client.Object,
	) (client.Object, error)
}

LifecycleCapabilities describes a set of behaviour needed to implement the Lifecycle capabilities

type ReconcilerHookResult

type ReconcilerHookResult struct {
	Result             ctrl.Result
	Err                error
	StopReconciliation bool
}

ReconcilerHookResult is the result of a reconciliation loop

type WalCapabilities

type WalCapabilities interface {
	// ArchiveWAL calls the loaded plugins to archive a WAL file.
	// This call is a no-op if there's no plugin implementing WAL archiving
	ArchiveWAL(
		ctx context.Context,
		cluster client.Object,
		sourceFileName string,
	) error

	// RestoreWAL calls the loaded plugins to archive a WAL file.
	// This call is a no-op if there's no plugin implementing WAL archiving
	RestoreWAL(
		ctx context.Context,
		cluster client.Object,
		sourceWALName string,
		destinationFileName string,
	) error
}

WalCapabilities describes a set of behavior needed to archive and recover WALs

Jump to

Keyboard shortcuts

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