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 ¶
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 ¶
type Client interface { Connection ClusterCapabilities ClusterReconcilerHooks LifecycleCapabilities WalCapabilities BackupCapabilities }
Client describes a set of behaviour needed to properly handle all the plugin client expected features
func NewUnixSocketClient ¶
NewUnixSocketClient creates a new CNPI client discovering plugins registered in a specific path
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, oldObject client.Object, newObject client.Object, ) (field.ErrorList, 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 { // Load connect to the plugin with the specified name Load(ctx context.Context, name string) error // Close closes the connection to every loaded plugin Close(ctx context.Context) // MetadataList exposes the metadata of the loaded plugins MetadataList() []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 Loader ¶
type Loader interface { // LoadPluginClient creates a new plugin client, loading the plugins that are required // by this cluster LoadPluginClient(ctx context.Context) (Client, error) }
Loader describes a struct capable of generating a plugin Client
type Metadata ¶
type Metadata struct { Name string Version string Capabilities []string OperatorCapabilities []string WALCapabilities []string BackupCapabilities []string }
Metadata expose the metadata as discovered from a plugin
type ReconcilerHookResult ¶
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