1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-17 01:12:23 +02:00

Add Perl interface to C storage layer.

Maintaining the storage layer/drivers in two languages is burdensome.  Since the integration tests require the Perl storage layer/drivers we'll need them even after the core code is migrated to C.  Create an interface layer so the Perl code can be removed and new storage drivers/features introduced without adding Perl equivalents.

The goal is to move the integration tests to C so this interface will eventually be removed.  That being the case, the interface was designed for maximum compatibility to ease the transition.  The result looks a bit hacky but we'll improve it as needed until it can be retired.
This commit is contained in:
David Steele
2019-06-26 08:24:58 -04:00
parent bd6c0941e9
commit 4815752ccc
93 changed files with 4412 additions and 12102 deletions

View File

@ -13,16 +13,10 @@ use File::Basename qw(basename);
use pgBackRest::Common::Log;
use pgBackRest::Config::Config;
use pgBackRest::Storage::Posix::Driver;
use pgBackRest::Storage::Local;
use pgBackRest::Storage::Base;
use pgBackRest::Storage::Storage;
use pgBackRest::Version;
####################################################################################################################################
# Storage constants
####################################################################################################################################
use constant STORAGE_LOCAL => '<LOCAL>';
push @EXPORT, qw(STORAGE_LOCAL);
####################################################################################################################################
# Compression extension
####################################################################################################################################
@ -35,11 +29,6 @@ use constant COMPRESS_EXT => 'gz';
use constant STORAGE_TEMP_EXT => PROJECT_EXE . '.tmp';
push @EXPORT, qw(STORAGE_TEMP_EXT);
####################################################################################################################################
# Cache storage so it can be retrieved quickly
####################################################################################################################################
my $hStorage;
####################################################################################################################################
# storageLocal - get local storage
#
@ -49,32 +38,13 @@ my $hStorage;
sub storageLocal
{
# Assign function parameters, defaults, and log debug info
my
(
$strOperation,
$strPath,
) =
logDebugParam
(
__PACKAGE__ . '::storageLocal', \@_,
{name => 'strPath', default => '/', trace => true},
);
# Create storage if not defined
if (!defined($hStorage->{&STORAGE_LOCAL}{$strPath}))
{
# Create local storage
$hStorage->{&STORAGE_LOCAL}{$strPath} = new pgBackRest::Storage::Local(
$strPath, new pgBackRest::Storage::Posix::Driver(),
{strTempExtension => STORAGE_TEMP_EXT,
lBufferMax => cfgOptionValid(CFGOPT_BUFFER_SIZE, false) ? cfgOption(CFGOPT_BUFFER_SIZE, false) : undef});
}
my ($strOperation) = logDebugParam(__PACKAGE__ . '::storageLocal');
# Return from function and log return values if any
return logDebugReturn
(
$strOperation,
{name => 'oStorageLocal', value => $hStorage->{&STORAGE_LOCAL}{$strPath}, trace => true},
{name => 'oStorageLocal', value => new pgBackRest::Storage::Storage(STORAGE_LOCAL), trace => true},
);
}