1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00
pgbackrest/doc
David Steele ed0d48f52c Add StringId type.
It is often useful to represent identifiers as strings when they cannot easily be represented as an enum/integer, e.g. because they are distributed among a number of unrelated modules or need to be passed to remote processes. Strings are also more helpful in debugging since they can be recognized without cross-referencing the source. However, strings are awkward to work with in C since they cannot be directly used in switch statements leading to less efficient if-else structures.

A StringId encodes a short string into an integer so it can be used in switch statements but may also be readily converted back into a string for debugging purposes. StringIds may also be suitable for matching user input providing the strings are short enough.

This patch includes a sample of StringId usage by converting protocol commands to StringIds. There are many other possible use cases. To list a few:

* All "types" in storage, filters. IO , etc. These types are primarily for identification and debugging so they fit well with this model.

* MemContext names would work well as StringIds since these are entirely for debugging.

* Option values could be represented as StringIds which would mean we could remove the functions that convert strings to enums, e.g. CipherType.

* There are a number of places where enums need to be converted back to strings for logging/debugging purposes. An example is protocolParallelJobToConstZ. If ProtocolParallelJobState were defined as:

typedef enum
{
    protocolParallelJobStatePending = STRID5("pend", ...),
    protocolParallelJobStateRunning = STRID5("run", ...),
    protocolParallelJobStateDone = STRID5("done", ...),
} ProtocolParallelJobState;

then protocolParallelJobToConstZ() could be replaced with strIdToZ(). This also applies to many enums that we don't covert to strings for logging, such as CipherMode.

As an example of usage, convert all protocol commands from strings to StringIds.
2021-04-20 15:22:42 -04:00
..
example JSON output from the info command is no longer pretty-printed. 2019-10-11 12:56:03 -04:00
lib/pgBackRestDoc Move configuration definition to src/build/config/config.yaml. 2021-03-08 16:01:05 -05:00
resource Begin v2.34 development. 2021-04-05 10:23:16 -04:00
xml Add StringId type. 2021-04-20 15:22:42 -04:00
.gitignore Fix .gitignore in doc directory. 2021-03-05 08:41:15 -05:00
doc.pl Move pgBackRest::Version module to pgBackRestDoc::ProjectInfo. 2020-03-10 17:57:02 -04:00
FORMAT.md Add notes about optional symlinks to repo format 6 design. 2020-09-01 11:02:44 -04:00
manifest.xml Remove XML source for test/README.md. 2020-04-20 16:21:53 -04:00
README.md Add RHEL/CentOS 8 documentation. 2020-12-04 10:59:57 -05:00
RELEASE.md v2.33: Multi-Repository and GCS Support 2021-04-05 09:18:20 -04:00
release.pl v2.32: Repository Commands 2021-02-08 09:08:16 -05:00

pgBackRest
Building Documentation

General Builds

The pgBackRest documentation can output a variety of formats and target several platforms and PostgreSQL versions.

This will build all documentation with defaults:

./doc.pl

The user guide can be built for different platforms: centos7, centos8 and debian. This will build the HTML user guide for CentOS/RHEL 7:

./doc.pl --out=html --include=user-guide --var=os-type=centos7

Documentation generation will build a cache of all executed statements and use the cache to build the documentation quickly if no executed statements have changed. This makes proofing text-only edits very fast, but sometimes it is useful to do a full build without using the cache:

./doc.pl --out=html --include=user-guide --var=os-type=centos8 --no-cache

Each os-type has a default container image that will be used as a base for creating hosts. For centos7/centos8 these defaults are generally fine, but for debian it can be useful to change the image.

./doc.pl --out=html --include=user-guide --var=os-type=debian --var=os-image=debian:9

The following is a sample CentOS/RHEL 7 configuration that can be used for building the documentation.

# Install docker
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install -y docker-ce
sudo systemctl start docker

# Install tools
sudo yum install -y git wget

# Install latex (for building PDF)
sudo yum install -y texlive texlive-titlesec texlive-sectsty texlive-framed texlive-epstopdf ghostscript

# Install Perl modules that do not have CentOS packages via CPAN
sudo yum install -y yum cpanminus
sudo yum groupinstall -y "Development Tools" "Development Libraries"
sudo cpanm install --force XML::Checker::Parser

# Add documentation test user
sudo groupadd test
sudo adduser -gtest -n testdoc
sudo usermod -aG docker testdoc

Building with Packages

A user-specified package can be used when building the documentation. Since the documentation exercises most pgBackRest functionality this is a great way to smoke-test packages.

The package must be located within the pgBackRest repo and the specified path should be relative to the repository base. test/package is a good default path to use.

Ubuntu 16.04:

./doc.pl --out=html --include=user-guide --no-cache --var=os-type=debian --var=os-image=ubuntu:16.04 --var=package=test/package/pgbackrest_2.08-0_amd64.deb

CentOS/RHEL 7:

./doc.pl --out=html --include=user-guide --no-cache --var=os-type=centos7 --var=package=test/package/pgbackrest-2.08-1.el7.x86_64.rpm

CentOS/RHEL 8:

./doc.pl --out=html --include=user-guide --no-cache --var=os-type=centos8 --var=package=test/package/pgbackrest-2.08-1.el8.x86_64.rpm

Packages can be built with test.pl using the following configuration on top of the configuration given for building the documentation.

# Install recent git
sudo yum remove -y git
sudo yum install -y https://centos7.iuscommunity.org/ius-release.rpm
sudo yum install -y git2u-all

# Install Perl modules
sudo yum install -y perl-ExtUtils-ParseXS perl-ExtUtils-Embed perl-ExtUtils-MakeMaker perl-YAML-LibYAML

# Install dev libraries
sudo yum install -y libxml2-devel openssl-devel

# Add test user with sudo privileges
sudo adduser -gtest -n test
sudo usermod -aG docker test
sudo chmod 750 /home/test

sudo echo 'test ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/pgbackrest

# Add pgbackrest user required by tests
sudo adduser -gtest -n pgbackrest