Documentation ¶
Overview ¶
Package common contains reusable structs and methods for CNPGI plugins.
Index ¶
- Constants
- Variables
- func AddHealthCheck(server *grpc.Server)
- func GetRestoreCABundleEnv(configuration *barmanapi.BarmanObjectStoreConfiguration) []string
- func IsWALFile(name string) bool
- func MergeEnv(env []string, incomingEnv []string) []string
- func WalSegmentsPerFile(walSegmentSize int64) int32
- type Segment
- type WALServiceImplementation
- func (w WALServiceImplementation) Archive(ctx context.Context, request *wal.WALArchiveRequest) (*wal.WALArchiveResult, error)
- func (w WALServiceImplementation) GetCapabilities(_ context.Context, _ *wal.WALCapabilitiesRequest) (*wal.WALCapabilitiesResult, error)
- func (w WALServiceImplementation) Restore(ctx context.Context, request *wal.WALRestoreRequest) (*wal.WALRestoreResult, error)
- func (w WALServiceImplementation) SetFirstRequired(_ context.Context, _ *wal.SetFirstRequiredRequest) (*wal.SetFirstRequiredResult, error)
- func (w WALServiceImplementation) Status(_ context.Context, _ *wal.WALStatusRequest) (*wal.WALStatusResult, error)
Constants ¶
const ( // ScratchDataDirectory is the directory to be used for scratch data. ScratchDataDirectory = "/controller" // CertificatesDir location to store the certificates. CertificatesDir = ScratchDataDirectory + "/certificates/" // BarmanBackupEndpointCACertificateLocation is the location where the barman endpoint // CA certificate is stored. BarmanBackupEndpointCACertificateLocation = CertificatesDir + BarmanBackupEndpointCACertificateFileName // BarmanBackupEndpointCACertificateFileName is the name of the file in which the barman endpoint // CA certificate for backups is stored. BarmanBackupEndpointCACertificateFileName = "backup-" + BarmanEndpointCACertificateFileName // BarmanRestoreEndpointCACertificateFileName is the name of the file in which the barman endpoint // CA certificate for restores is stored. BarmanRestoreEndpointCACertificateFileName = "restore-" + BarmanEndpointCACertificateFileName // BarmanEndpointCACertificateFileName is the name of the file in which the barman endpoint // CA certificate is stored. BarmanEndpointCACertificateFileName = "barman-ca.crt" )
TODO: refactor.
const ( // DefaultWALSegmentSize is the default size of a single WAL file // This must be a power of 2. DefaultWALSegmentSize = int64(1 << 24) // WALHexOctetRe is a regex to match 8 Hex characters. WALHexOctetRe = `([\dA-Fa-f]{8})` // WALTimeLineRe is a regex to match the timeline in a WAL filename. WALTimeLineRe = WALHexOctetRe // WALSegmentNameRe is a regex to match the segment parent log file and segment id. WALSegmentNameRe = WALHexOctetRe + WALHexOctetRe )
Variables ¶
var ( // WALRe is the file segment name parser. WALRe = regexp.MustCompile(`^` + WALTimeLineRe + `(?:` + WALSegmentNameRe + `(?:` + `\.[\dA-Fa-f]{8}\.backup` + `|` + `\.partial` + `)?` + `|` + `\.history` + `)$`) // WALSegmentRe is the file segment name parser. WALSegmentRe = regexp.MustCompile(`^` + WALTimeLineRe + WALSegmentNameRe + `$`) // ErrBadWALSegmentName is raised when parsing an invalid segment name. ErrBadWALSegmentName = errors.New("invalid WAL segment name") )
var ErrEndOfWALStreamReached = errors.New("end of WAL reached")
ErrEndOfWALStreamReached is returned when end of WAL is detected in the cloud archive.
Functions ¶
func AddHealthCheck ¶
AddHealthCheck adds a health check service to the gRPC server with the tag 'plugin-barman-cloud'
func GetRestoreCABundleEnv ¶
func GetRestoreCABundleEnv(configuration *barmanapi.BarmanObjectStoreConfiguration) []string
GetRestoreCABundleEnv gets the enveronment variables to be used when custom Object Store CA is present
func IsWALFile ¶
IsWALFile check if the passed file name is a regular WAL file. It supports either a full file path or a simple file name.
func WalSegmentsPerFile ¶
WalSegmentsPerFile is the number of WAL Segments in a WAL File.
Types ¶
type Segment ¶
type Segment struct { // Timeline number Tli int32 // Log number Log int32 // Segment number Seg int32 }
Segment contains the information inside a WAL segment name.
func MustSegmentFromName ¶
MustSegmentFromName is analogous to SegmentFromName but panics if the segment name is invalid.
func SegmentFromName ¶
SegmentFromName retrieves the timeline, log ID and segment ID from the name of a xlog segment, and can also handle a full path or a simple file name.
func (Segment) NextSegments ¶
NextSegments generate the list of all possible segment names starting from `segment`, until the specified size is reached. This function will not ever generate timeline changes. If postgresVersion == nil, the latest postgres version is assumed. If segmentSize == nil, wal_segment_size=DefaultWALSegmentSize is assumed.
type WALServiceImplementation ¶
type WALServiceImplementation struct { wal.UnimplementedWALServer Client client.Client InstanceName string SpoolDirectory string PGDataPath string PGWALPath string }
WALServiceImplementation is the implementation of the WAL Service
func (WALServiceImplementation) Archive ¶
func (w WALServiceImplementation) Archive( ctx context.Context, request *wal.WALArchiveRequest, ) (*wal.WALArchiveResult, error)
Archive implements the WALService interface
func (WALServiceImplementation) GetCapabilities ¶
func (w WALServiceImplementation) GetCapabilities( _ context.Context, _ *wal.WALCapabilitiesRequest, ) (*wal.WALCapabilitiesResult, error)
GetCapabilities implements the WALService interface
func (WALServiceImplementation) Restore ¶
func (w WALServiceImplementation) Restore( ctx context.Context, request *wal.WALRestoreRequest, ) (*wal.WALRestoreResult, error)
Restore implements the WALService interface nolint: gocognit
func (WALServiceImplementation) SetFirstRequired ¶
func (w WALServiceImplementation) SetFirstRequired( _ context.Context, _ *wal.SetFirstRequiredRequest, ) (*wal.SetFirstRequiredResult, error)
SetFirstRequired implements the WALService interface
func (WALServiceImplementation) Status ¶
func (w WALServiceImplementation) Status( _ context.Context, _ *wal.WALStatusRequest, ) (*wal.WALStatusResult, error)
Status implements the WALService interface