Documentation
¶
Index ¶
- Constants
- type BackupConfig
- type BackupRetentionConfig
- type BackupWalRetentionConfig
- type CompressionConfig
- type Config
- type DevConfig
- type DevConfigPprof
- type EncryptionConfig
- type LogConfig
- type MainConfig
- type MetricsConfig
- type ReceiveConfig
- type RetentionConfig
- type S3Config
- type SFTPConfig
- type StorageConfig
- type UploadConfig
Constants ¶
const ( // ModeReceive represents the WAL receiving mode. ModeReceive = "receive" // ModeServe represents the HTTP API serving mode. ModeServe = "serve" // ModeBackup used in pgrwl streaming basebackup mode. ModeBackup = "backup" // ModeBackupCMD used in pgrwl backup CLI command. ModeBackupCMD = "backup-cmd" // ModeRestoreCMD used in pgrwl restore CLI command. ModeRestoreCMD = "restore" // StorageNameS3 is the identifier for the S3 storage backend. StorageNameS3 = "s3" // StorageNameSFTP is the identifier for the SFTP storage backend. StorageNameSFTP = "sftp" // StorageNameLocalFS is the identifier for the local storage. StorageNameLocalFS = "local" // LocalFSStorageSubpath when storage name is 'local', uploader worker uses this as a storage. LocalFSStorageSubpath = "wal-archive" // BaseBackupSubpath when storage name is 'local', put basebackups to this directory. BaseBackupSubpath = "backups" // RepoEncryptorAes256Gcm is the AES-256-GCM encryption algorithm identifier. RepoEncryptorAes256Gcm = "aes-256-gcm" // RepoCompressorGzip is the Gzip compression algorithm identifier. RepoCompressorGzip = "gzip" // RepoCompressorZstd is the Zstandard compression algorithm identifier. RepoCompressorZstd = "zstd" BackupRetentionTypeTime = "time" BackupRetentionTypeCount = "count" )
Constants for application modes.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackupConfig ¶ added in v1.0.18
type BackupConfig struct {
Cron string `json:"cron" env:"PGRWL_BACKUP_CRON"`
Retention BackupRetentionConfig `json:"retention,omitzero"`
WalRetention BackupWalRetentionConfig `json:"walretention,omitzero"`
}
BackupConfig configures streaming basebackup properties.
type BackupRetentionConfig ¶ added in v1.0.18
type BackupRetentionConfig struct {
// Enable determines whether retention logic is active.
Enable bool `json:"enable,omitzero" env:"PGRWL_BACKUP_RETENTION_ENABLE"`
Type string `json:"type,omitzero" env:"PGRWL_BACKUP_RETENTION_TYPE"`
Value string `json:"value,omitzero" env:"PGRWL_BACKUP_RETENTION_VALUE"`
KeepDurationParsed time.Duration `json:"-"`
KeepCountParsed int64 `json:"-"`
KeepLast *int `json:"keep_last,omitzero" env:"PGRWL_BACKUP_RETENTION_KEEP_LAST"`
}
BackupRetentionConfig configures retention for basebackups.
type BackupWalRetentionConfig ¶ added in v1.0.23
type BackupWalRetentionConfig struct {
Enable bool `json:"enable,omitzero" env:"PGRWL_BACKUP_WALRETENTION_ENABLE"`
ReceiverAddr string `json:"receiver_addr,omitzero" env:"PGRWL_BACKUP_WALRETENTION_RECEIVER_ADDR"`
}
BackupWalRetentionConfig configures related setting for WAL-archive.
type CompressionConfig ¶
type CompressionConfig struct {
// Algo is the compression algorithm ("gzip", "zstd", etc.).
Algo string `json:"algo,omitzero" env:"PGRWL_STORAGE_COMPRESSION_ALGO"`
}
CompressionConfig defines the compression algorithm to use.
type Config ¶
type Config struct {
Main MainConfig `json:"main,omitzero"` // Main application settings.
Receiver ReceiveConfig `json:"receiver,omitzero"` // WAL receiver configuration.
Metrics MetricsConfig `json:"metrics,omitzero"` // Prometheus metrics configuration.
Log LogConfig `json:"log,omitzero"` // Logging configuration.
Storage StorageConfig `json:"storage,omitzero"` // Storage backend configuration.
DevConfig DevConfig `json:"devconfig,omitzero"` // Various dev options.
Backup BackupConfig `json:"backup,omitzero"` // Streaming basebackup options.
}
Config is the root configuration for the WAL receiver application. Supports `${PGRWL_*}` environment variable placeholders for sensitive values.
func MustEnvconfig ¶ added in v1.0.23
func (*Config) IsExternalStor ¶ added in v1.0.7
func (*Config) IsLocalStor ¶ added in v1.0.7
type DevConfig ¶ added in v1.0.6
type DevConfig struct {
Pprof DevConfigPprof `json:"pprof,omitzero"`
}
DevConfig configures development-only features like profiling and debug endpoints.
type DevConfigPprof ¶ added in v1.0.6
type DevConfigPprof struct {
Enable bool `json:"enable,omitzero" env:"PGRWL_DEVCONFIG_PPROF_ENABLE"`
}
DevConfigPprof configures pprof.
type EncryptionConfig ¶
type EncryptionConfig struct {
// Algo is the encryption algorithm identifier ("aes-256-gcm", etc.).
Algo string `json:"algo,omitzero" env:"PGRWL_STORAGE_ENCRYPTION_ALGO"`
// Pass is the encryption passphrase.
Pass string `json:"pass,omitzero" env:"PGRWL_STORAGE_ENCRYPTION_PASS"`
}
EncryptionConfig defines the encryption algorithm and credentials.
type LogConfig ¶
type LogConfig struct {
// Level sets the log level (e.g., "trace", "debug", "info", "warn", "error").
Level string `json:"level,omitzero" env:"PGRWL_LOG_LEVEL"`
// Format sets the log format ("text" or "json").
Format string `json:"format,omitzero" env:"PGRWL_LOG_FORMAT"`
// AddSource includes source file and line in log entries.
AddSource bool `json:"add_source,omitzero" env:"PGRWL_LOG_ADD_SOURCE"`
}
LogConfig defines application logging options.
type MainConfig ¶
type MainConfig struct {
// ListenPort is the TCP port for the management HTTP server.
ListenPort int `json:"listen_port,omitzero" env:"PGRWL_MAIN_LISTEN_PORT"`
// Directory is the base directory where WAL files and metadata are stored.
Directory string `json:"directory,omitzero" env:"PGRWL_MAIN_DIRECTORY"`
}
MainConfig holds top-level application settings.
type MetricsConfig ¶ added in v1.0.3
type MetricsConfig struct {
// Enable turns on Prometheus metrics HTTP endpoint.
Enable bool `json:"enable,omitzero" env:"PGRWL_METRICS_ENABLE"`
}
MetricsConfig enables or disables Prometheus metrics exposure.
type ReceiveConfig ¶
type ReceiveConfig struct {
// Slot is the replication slot name used to stream WAL from PostgreSQL.
Slot string `json:"slot,omitzero" env:"PGRWL_RECEIVER_SLOT"`
// NoLoop disables automatic reconnection loops on connection loss.
NoLoop bool `json:"no_loop,omitzero" env:"PGRWL_RECEIVER_NO_LOOP"`
// Uploader worker configuration.
Uploader UploadConfig `json:"uploader,omitzero"`
// Retention policy configuration.
Retention RetentionConfig `json:"retention,omitzero"`
}
ReceiveConfig configures the WAL receiving logic.
type RetentionConfig ¶ added in v1.0.2
type RetentionConfig struct {
// Enable determines whether retention logic is active.
Enable bool `json:"enable,omitzero" env:"PGRWL_RECEIVER_RETENTION_ENABLE"`
// SyncInterval is the interval between retention scans (e.g., "12h").
// Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
SyncInterval string `json:"sync_interval" env:"PGRWL_RECEIVER_RETENTION_SYNC_INTERVAL"`
SyncIntervalParsed time.Duration `json:"-"`
// KeepPeriod defines how long to keep old WAL files (e.g., "72h").
KeepPeriod string `json:"keep_period,omitzero" env:"PGRWL_RECEIVER_RETENTION_KEEP_PERIOD"`
KeepPeriodParsed time.Duration `json:"-"`
}
RetentionConfig configures the WAL file retention worker.
type S3Config ¶
type S3Config struct {
// URL is the S3-compatible endpoint URL (e.g., "https://s3.amazonaws.com").
URL string `json:"url,omitzero" env:"PGRWL_STORAGE_S3_URL"`
// AccessKeyID is the S3 access key ID.
AccessKeyID string `json:"access_key_id,omitzero" env:"PGRWL_STORAGE_S3_ACCESS_KEY_ID"`
// SecretAccessKey is the S3 secret access key.
SecretAccessKey string `json:"secret_access_key,omitzero" env:"PGRWL_STORAGE_S3_SECRET_ACCESS_KEY"`
// Bucket is the name of the S3 bucket to store WAL files.
Bucket string `json:"bucket,omitzero" env:"PGRWL_STORAGE_S3_BUCKET"`
// Region is the AWS region (for Amazon S3).
Region string `json:"region,omitzero" env:"PGRWL_STORAGE_S3_REGION"`
// UsePathStyle forces path-style requests instead of virtual-hosted style.
UsePathStyle bool `json:"use_path_style,omitzero" env:"PGRWL_STORAGE_S3_USE_PATH_STYLE"`
// DisableSSL disables HTTPS for connections to the S3 endpoint.
DisableSSL bool `json:"disable_ssl,omitzero" env:"PGRWL_STORAGE_S3_DISABLE_SSL"`
}
S3Config defines configuration for S3-compatible object storage.
type SFTPConfig ¶
type SFTPConfig struct {
// Host is the SFTP server hostname or IP.
Host string `json:"host,omitzero" env:"PGRWL_STORAGE_SFTP_HOST"`
// Port is the TCP port for the SFTP server.
Port int `json:"port,omitzero" env:"PGRWL_STORAGE_SFTP_PORT"`
// User is the username for SFTP authentication.
User string `json:"user,omitzero" env:"PGRWL_STORAGE_SFTP_USER"`
// Pass is the password for SFTP authentication (if not using a key).
Pass string `json:"pass,omitzero" env:"PGRWL_STORAGE_SFTP_PASS"`
// PKeyPath is the file path to the private key for key-based authentication.
PKeyPath string `json:"pkey_path,omitzero" env:"PGRWL_STORAGE_SFTP_PKEY_PATH"`
// PKeyPass is the passphrase for the private key, if encrypted.
PKeyPass string `json:"pkey_pass,omitzero" env:"PGRWL_STORAGE_SFTP_PKEY_PASS"`
// Base directory with sufficient user permissions
BaseDir string `json:"base_dir,omitzero" env:"PGRWL_STORAGE_SFTP_BASE_DIR"`
}
SFTPConfig defines parameters for connecting to an SFTP server.
type StorageConfig ¶
type StorageConfig struct {
// Name specifies the storage backend to use ("s3", "sftp", etc.).
Name string `json:"name,omitzero" env:"PGRWL_STORAGE_NAME"`
// Compression defines compression settings for stored WAL files.
Compression CompressionConfig `json:"compression,omitzero"`
// Encryption defines encryption settings for stored WAL files.
Encryption EncryptionConfig `json:"encryption,omitzero"`
// SFTP holds configuration specific to the SFTP backend.
SFTP SFTPConfig `json:"sftp,omitzero"`
// S3 holds configuration specific to the S3 backend.
S3 S3Config `json:"s3,omitzero"`
}
StorageConfig defines which storage backend to use and its options.
type UploadConfig ¶
type UploadConfig struct {
// SyncInterval is the interval between upload checks (e.g., "10s", "5m").
// Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
SyncInterval string `json:"sync_interval" env:"PGRWL_RECEIVER_UPLOADER_SYNC_INTERVAL"`
SyncIntervalParsed time.Duration `json:"-"`
// MaxConcurrency is the maximum number of concurrent upload tasks.
MaxConcurrency int `json:"max_concurrency" env:"PGRWL_RECEIVER_UPLOADER_MAX_CONCURRENCY"`
}
UploadConfig configures the uploader worker.