Documentation
¶
Index ¶
- func GetAllDefaults() map[string]string
- type BackupInfo
- type Conf
- type ConnectionType
- type DatabaseConfig
- type Duration
- type Extension
- type ExtensionConfig
- type ExtensionInfo
- type FieldInfo
- type PGAuditConf
- type PgAuthType
- type PgBouncer
- type PgBouncerConf
- type PgBouncerIni
- type PgBouncerStatus
- type PgHBAEntry
- type PgVersion
- type PgconfigSchemaJson
- type PoolInfo
- type PostgREST
- func (p *PostgREST) GetOpenAPISchema() (map[string]interface{}, error)
- func (p *PostgREST) GetStatus() (*PostgRESTStatus, error)
- func (p *PostgREST) Health() error
- func (p *PostgREST) Install(version, targetDir string) error
- func (p *PostgREST) InstalledVersion() (string, error)
- func (p *PostgREST) IsInstalled() bool
- func (p *PostgREST) Start() error
- func (p *PostgREST) Stop() error
- func (p *PostgREST) Validate(config []byte) error
- type PostgRESTStatus
- type PostgreSQLConfiguration
- type Postgres
- type PostgresConf
- type PostgrestConf
- type PostgrestHBA
- type PostgrestHBAMethod
- type PostgrestHBAType
- type Stats
- type ValidationError
- type WalG
- func (w *WalG) BackupFetch(backupName, targetDir string) error
- func (w *WalG) BackupList() ([]BackupInfo, error)
- func (w *WalG) BackupPush() error
- func (w *WalG) DeleteRetain(retainCount int) error
- func (w *WalG) GetStatus() (*WalgStatus, error)
- func (w *WalG) Health() error
- func (w *WalG) Install(version, targetDir string) error
- func (w *WalG) InstalledVersion() (string, error)
- func (w *WalG) IsInstalled() bool
- type WalgConf
- type WalgStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAllDefaults ¶
GetAllDefaults extracts all default values from the Conf struct
Types ¶
type BackupInfo ¶
type BackupInfo struct {
BackupName string `json:"backup_name"`
StartTime time.Time `json:"start_time"`
FinishTime time.Time `json:"finish_time"`
UncompressedSize int64 `json:"uncompressed_size"`
CompressedSize int64 `json:"compressed_size"`
DataSize int64 `json:"data_size"`
IsPermanent bool `json:"is_permanent"`
}
BackupInfo represents information about a WAL-G backup
type Conf ¶
type Conf = PgconfigSchemaJson
Backward compatibility aliases - the old types now map to the schema-generated types
type ConnectionType ¶ added in v1.0.4
type ConnectionType string
ConnectionType represents the connection type
const ( ConnectionTypeLocal ConnectionType = "local" ConnectionTypeHost ConnectionType = "host" ConnectionTypeSSL ConnectionType = "hostssl" ConnectionTypeNoSSL ConnectionType = "hostnossl" )
type DatabaseConfig ¶
type DatabaseConfig struct {
Host string `json:"host,omitempty" yaml:"host,omitempty" jsonschema:"description=Database host address,default=localhost"`
Port int `json:"port,omitempty" yaml:"port,omitempty" jsonschema:"description=Database port,default=5432,minimum=1,maximum=65535"`
Dbname *string `json:"dbname,omitempty" yaml:"dbname,omitempty" jsonschema:"description=Database name to connect to"`
User *string `json:"user,omitempty" yaml:"user,omitempty" jsonschema:"description=Username for database connection"`
Password *string `json:"password,omitempty" yaml:"password,omitempty" jsonschema:"description=Password for database connection"`
PoolSize *int `json:"pool_size,omitempty" yaml:"pool_size,omitempty" jsonschema:"description=Maximum pool size for this database,minimum=0"`
ConnectQuery *string `json:"connect_query,omitempty" yaml:"connect_query,omitempty" jsonschema:"description=Query to run on each new connection"`
}
DatabaseConfig represents database configuration for PgBouncer
type ExtensionConfig ¶
type ExtensionConfig struct {
Enabled bool `json:"enabled"`
Version *string `json:"version,omitempty"`
Name string `json:"name"`
ConfigFile *string `json:"config_file,omitempty"`
}
Extension configuration
type ExtensionInfo ¶
type ExtensionInfo struct {
Name string `json:"name"`
Version string `json:"version"`
Available bool `json:"available,omitempty"`
}
ExtensionInfo represents information about a PostgreSQL extension
type FieldInfo ¶
type FieldInfo struct {
Name string
KoanfPath string
EnvVar string
Default string
Description string
Type string
}
GetFieldInfo returns information about all configuration fields
func GetAllFieldInfo ¶
func GetAllFieldInfo() []FieldInfo
type PGAuditConf ¶
type PGAuditConf struct {
Log string `` /* 200-byte string literal not displayed */
LogCatalog string `` /* 145-byte string literal not displayed */
LogClient string `` /* 132-byte string literal not displayed */
LogLevel string `` /* 252-byte string literal not displayed */
LogParameter string `` /* 148-byte string literal not displayed */
LogParameterMaxSize string `` /* 175-byte string literal not displayed */
LogRelation string `` /* 154-byte string literal not displayed */
LogStatement string `` /* 149-byte string literal not displayed */
LogStatementOnce string `` /* 154-byte string literal not displayed */
Role *string `json:"role,omitempty" yaml:"role,omitempty" jsonschema:"description=Database role to use for auditing"`
}
PGAuditConf represents PGAudit extension configuration
type PgAuthType ¶ added in v1.0.4
type PgAuthType string
PgAuthType represents the authentication method
const ( AuthTrust PgAuthType = "trust" AuthReject PgAuthType = "reject" AuthMD5 PgAuthType = "md5" AuthPassword PgAuthType = "password" AuthScramSHA PgAuthType = "scram-sha-256" AuthPeer PgAuthType = "peer" AuthIdent PgAuthType = "ident" AuthCert PgAuthType = "cert" )
type PgBouncer ¶
type PgBouncer struct {
Config *PgBouncerConf
}
PgBouncer represents a PgBouncer connection pooler service instance
func NewPgBouncer ¶
func NewPgBouncer(config *PgBouncerConf) *PgBouncer
NewPgBouncer creates a new PgBouncer service instance
func (*PgBouncer) GetStatus ¶
func (p *PgBouncer) GetStatus() (*PgBouncerStatus, error)
GetStatus returns detailed PgBouncer service status
type PgBouncerConf ¶
type PgBouncerConf struct {
Databases map[string]DatabaseConfig `json:"databases,omitempty" yaml:"databases,omitempty" jsonschema:"description=Database connection configurations"`
ListenAddr string `` /* 149-byte string literal not displayed */
ListenAddress string `` /* 139-byte string literal not displayed */
ListenPort int `` /* 151-byte string literal not displayed */
AuthType string `` /* 211-byte string literal not displayed */
AuthFile string `` /* 127-byte string literal not displayed */
AuthQuery string `` /* 172-byte string literal not displayed */
PoolMode string `` /* 163-byte string literal not displayed */
MaxClientConn int `` /* 157-byte string literal not displayed */
DefaultPoolSize int `` /* 147-byte string literal not displayed */
MinPoolSize int `json:"min_pool_size,omitempty" yaml:"min_pool_size,omitempty" jsonschema:"description=Minimum pool size,default=0,minimum=0"`
ReservePoolSize *int `json:"reserve_pool_size,omitempty" yaml:"reserve_pool_size,omitempty" jsonschema:"description=Reserved pool size,minimum=0"`
ServerLifetime string `` /* 152-byte string literal not displayed */
ServerIdleTimeout string `` /* 174-byte string literal not displayed */
ClientIdleTimeout string `` /* 184-byte string literal not displayed */
QueryTimeout string `` /* 145-byte string literal not displayed */
AdminUser *string `json:"admin_user,omitempty" yaml:"admin_user,omitempty" jsonschema:"description=Administrative user for PgBouncer"`
AdminPassword *string `` /* 126-byte string literal not displayed */
}
PgBouncerConf represents PgBouncer configuration
type PgBouncerIni ¶
type PgBouncerIni = PgBouncerConf
type PgBouncerStatus ¶
type PgBouncerStatus struct {
Address string `json:"address"`
Healthy bool `json:"healthy"`
CheckTime time.Time `json:"check_time"`
AdminUser string `json:"admin_user"`
PoolCount int `json:"pool_count"`
TotalClients int `json:"total_clients"`
TotalServers int `json:"total_servers"`
Error string `json:"error,omitempty"`
}
PgBouncerStatus represents the status of a PgBouncer service
type PgHBAEntry ¶ added in v1.0.4
type PgHBAEntry struct {
Type ConnectionType `json:"type,omitempty" yaml:"type,omitempty"`
Database string `json:"database,omitempty" yaml:"database,omitempty"`
User string `json:"user,omitempty" yaml:"user,omitempty"`
Address string `json:"address,omitempty" yaml:"address,omitempty"`
Method PgAuthType `json:"method,omitempty" yaml:"method,omitempty"`
Options map[string]string `json:"options,omitempty" yaml:"options,omitempty"`
}
PgHBAEntry represents a pg_hba.conf rule element
type PgconfigSchemaJson ¶
type PgconfigSchemaJson struct {
Postgres *PostgresConf `json:"postgres,omitempty" yaml:"postgres,omitempty"`
Pgbouncer *PgBouncerConf `json:"pgbouncer,omitempty" yaml:"pgbouncer,omitempty"`
Postgrest *PostgrestConf `json:"postgrest,omitempty" yaml:"postgrest,omitempty"`
Walg *WalgConf `json:"walg,omitempty" yaml:"walg,omitempty"`
Pgaudit *PGAuditConf `json:"pgaudit,omitempty" yaml:"pgaudit,omitempty"`
}
PgconfigSchemaJson represents the main configuration schema
func LoadConfig ¶
func LoadConfig(configFile string) (*PgconfigSchemaJson, error)
LoadConfig loads configuration from a YAML file using koanf with schema-based validation and defaults
type PoolInfo ¶
type PoolInfo struct {
Database string `json:"database"`
User string `json:"user"`
ClientActive int `json:"client_active"`
ClientWaiting int `json:"client_waiting"`
ServerActive int `json:"server_active"`
ServerIdle int `json:"server_idle"`
ServerUsed int `json:"server_used"`
ServerTested int `json:"server_tested"`
ServerLogin int `json:"server_login"`
MaxWait int `json:"max_wait"`
MaxWaitUs int `json:"max_wait_us"`
PoolMode string `json:"pool_mode"`
}
PoolInfo represents information about a connection pool
type PostgREST ¶
type PostgREST struct {
Config *PostgrestConf
}
PostgREST represents a PostgREST service instance
func NewPostgREST ¶
func NewPostgREST(config *PostgrestConf) *PostgREST
NewPostgREST creates a new PostgREST service instance
func (*PostgREST) GetOpenAPISchema ¶
GetOpenAPISchema retrieves the OpenAPI schema from PostgREST
func (*PostgREST) GetStatus ¶
func (p *PostgREST) GetStatus() (*PostgRESTStatus, error)
GetStatus returns detailed PostgREST service status
func (*PostgREST) Install ¶
Install installs PostgREST binary with optional version and target directory
func (*PostgREST) InstalledVersion ¶
InstalledVersion returns the installed PostgREST version
func (*PostgREST) IsInstalled ¶
IsInstalled checks if PostgREST is installed in PATH
func (*PostgREST) Start ¶
Start starts the PostgREST service (placeholder for future implementation)
type PostgRESTStatus ¶
type PostgRESTStatus struct {
URL string `json:"url"`
Healthy bool `json:"healthy"`
CheckTime time.Time `json:"check_time"`
AdminRole string `json:"admin_role"`
AnonymousRole string `json:"anonymous_role"`
Error string `json:"error,omitempty"`
}
PostgRESTStatus represents the status of a PostgREST service
type PostgreSQLConfiguration ¶
type PostgreSQLConfiguration = PgconfigSchemaJson
type Postgres ¶
type Postgres interface {
DescribeConfig() ([]interface{}, error)
DetectVersion() (int, error)
Health() error
IsRunning() bool
Start() error
Stop() error
Exists() bool
GetVersion() PgVersion
Validate(config []byte) error
SQL(sqlQuery string) ([]map[string]interface{}, error)
}
Postgres interface for backward compatibility This allows existing code to work while server implementations are concrete
type PostgresConf ¶
type PostgresConf struct {
// Memory Settings
EffectiveCacheSize types.Size `` /* 173-byte string literal not displayed */
WorkMem types.Size `` /* 157-byte string literal not displayed */
MaintenanceWorkMem types.Size `` /* 162-byte string literal not displayed */
WalBuffers types.Size `` /* 144-byte string literal not displayed */
// Connection Settings
MaxConnections int `` /* 162-byte string literal not displayed */
ListenAddresses string `` /* 191-byte string literal not displayed */
Port int `` /* 145-byte string literal not displayed */
PasswordEncryption string `` /* 192-byte string literal not displayed */
// WAL Settings
WalLevel string `` /* 182-byte string literal not displayed */
MinWalSize types.Size `` /* 127-byte string literal not displayed */
MaxWalSize types.Size `` /* 163-byte string literal not displayed */
CheckpointCompletionTarget float64 `` /* 235-byte string literal not displayed */
ArchiveMode string `` /* 155-byte string literal not displayed */
ArchiveCommand string `` /* 155-byte string literal not displayed */
ArchiveTimeout types.Duration `` /* 167-byte string literal not displayed */
MaxWalSenders int `` /* 172-byte string literal not displayed */
// Query Optimization
RandomPageCost float64 `` /* 183-byte string literal not displayed */
EffectiveIoConcurrency int `` /* 204-byte string literal not displayed */
DefaultStatisticsTarget int `` /* 208-byte string literal not displayed */
// Parallel Processing
MaxWorkerProcesses int `` /* 186-byte string literal not displayed */
MaxParallelWorkers int `` /* 202-byte string literal not displayed */
MaxParallelWorkersPerGather int `` /* 196-byte string literal not displayed */
MaxParallelMaintenanceWorkers int `` /* 206-byte string literal not displayed */
// Logging
LogStatement string `` /* 171-byte string literal not displayed */
LogConnections bool `` /* 136-byte string literal not displayed */
LogDisconnections bool `` /* 151-byte string literal not displayed */
LogMinDurationStatement types.Duration `` /* 206-byte string literal not displayed */
LogLinePrefix string `` /* 153-byte string literal not displayed */
LogDestination string `` /* 198-byte string literal not displayed */
// SSL/Security
SSL bool `json:"ssl,omitempty" yaml:"ssl,omitempty" jsonschema:"description=Enables SSL connections,default=false"`
SSLCertFile string `` /* 130-byte string literal not displayed */
SSLKeyFile string `` /* 128-byte string literal not displayed */
// Autovacuum
Autovacuum bool `` /* 126-byte string literal not displayed */
AutovacuumMaxWorkers int `` /* 192-byte string literal not displayed */
AutovacuumNaptime types.Duration `` /* 147-byte string literal not displayed */
SharedPreloadLibraries string `` /* 154-byte string literal not displayed */
// Huge Pages
HugePages string `` /* 145-byte string literal not displayed */
// Allow additional PostgreSQL configuration parameters not explicitly defined above
AdditionalProperties map[string]interface{} `json:"-" yaml:"-"`
}
PostgresConf represents the PostgreSQL server configuration with the most commonly used settings. Additional properties can be set via the AdditionalProperties field.
func (PostgresConf) MarshalJSON ¶
func (p PostgresConf) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling to include additional properties
func (*PostgresConf) UnmarshalJSON ¶
func (p *PostgresConf) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling to handle additional properties
type PostgrestConf ¶
type PostgrestConf struct {
DbUri *string `json:"db_uri,omitempty" yaml:"db_uri,omitempty" jsonschema:"description=PostgreSQL connection string"`
DbSchemas *string `` /* 131-byte string literal not displayed */
DbAnonRole *string `json:"db_anon_role,omitempty" yaml:"db_anon_role,omitempty" jsonschema:"description=Database role for anonymous access"`
DbPool *int `` /* 167-byte string literal not displayed */
DbPoolSize *int `` /* 147-byte string literal not displayed */
ServerHost *string `` /* 132-byte string literal not displayed */
ServerPort *int `` /* 153-byte string literal not displayed */
JwtSecret *string `json:"jwt_secret,omitempty" yaml:"jwt_secret,omitempty" jsonschema:"description=JWT secret for authentication"`
JwtAud *string `json:"jwt_aud,omitempty" yaml:"jwt_aud,omitempty" jsonschema:"description=JWT audience claim"`
MaxRows *int `json:"max_rows,omitempty" yaml:"max_rows,omitempty" jsonschema:"description=Maximum number of rows in a response,minimum=1"`
PreRequest *string `json:"pre_request,omitempty" yaml:"pre_request,omitempty" jsonschema:"description=Function to call before each request"`
RoleClaimKey *string `` /* 137-byte string literal not displayed */
AdminRole string `json:"admin_role,omitempty" yaml:"admin_role,omitempty" jsonschema:"description=Database role for admin access"`
AnonymousRole string `` /* 129-byte string literal not displayed */
LogLevel *string `` /* 156-byte string literal not displayed */
}
PostgrestConf represents PostgREST configuration
type PostgrestHBA ¶
type PostgrestHBA = PgHBAEntry
type PostgrestHBAMethod ¶
type PostgrestHBAMethod = PgAuthType
type PostgrestHBAType ¶
type PostgrestHBAType = ConnectionType
type Stats ¶
type Stats struct {
Database string `json:"database"`
TotalXactCount int64 `json:"total_xact_count"`
TotalQueryCount int64 `json:"total_query_count"`
TotalReceived int64 `json:"total_received"`
TotalSent int64 `json:"total_sent"`
TotalXactTime int64 `json:"total_xact_time"`
TotalQueryTime int64 `json:"total_query_time"`
TotalWaitTime int64 `json:"total_wait_time"`
AvgXactCount int64 `json:"avg_xact_count"`
AvgQueryCount int64 `json:"avg_query_count"`
AvgReceived int64 `json:"avg_received"`
AvgSent int64 `json:"avg_sent"`
AvgXactTime int64 `json:"avg_xact_time"`
AvgQueryTime int64 `json:"avg_query_time"`
AvgWaitTime int64 `json:"avg_wait_time"`
}
Stats represents PgBouncer statistics
type ValidationError ¶
type ValidationError struct {
Line int // Line number if available
Parameter string // Parameter name that failed
Message string // Error description
Raw string // Original error message
}
ValidationError provides detailed validation error information
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
type WalG ¶
type WalG struct {
Config *WalgConf
}
WalG represents a WAL-G backup service instance
func (*WalG) BackupFetch ¶
BackupFetch restores a backup by name
func (*WalG) BackupList ¶
func (w *WalG) BackupList() ([]BackupInfo, error)
BackupList retrieves the list of available backups
func (*WalG) BackupPush ¶
BackupPush creates a new backup using WAL-G
func (*WalG) DeleteRetain ¶
DeleteRetain deletes old backups, keeping the specified number
func (*WalG) GetStatus ¶
func (w *WalG) GetStatus() (*WalgStatus, error)
GetStatus returns detailed WAL-G service status
func (*WalG) InstalledVersion ¶
InstalledVersion returns the installed WAL-G version
func (*WalG) IsInstalled ¶
IsInstalled checks if WAL-G is installed in PATH
type WalgConf ¶
type WalgConf struct {
Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty" jsonschema:"description=Enable WAL-G backup and recovery,default=false"`
S3Bucket *string `json:"s3_bucket,omitempty" yaml:"s3_bucket,omitempty" jsonschema:"description=S3 bucket name for backups"`
S3Endpoint *string `json:"s3_endpoint,omitempty" yaml:"s3_endpoint,omitempty" jsonschema:"description=S3 endpoint URL for S3-compatible storage"`
S3AccessKeyId *string `json:"s3_access_key_id,omitempty" yaml:"s3_access_key_id,omitempty" jsonschema:"description=S3 access key ID"`
S3SecretAccessKey *string `json:"s3_secret_access_key,omitempty" yaml:"s3_secret_access_key,omitempty" jsonschema:"description=S3 secret access key"`
S3AccessKey *string `` /* 134-byte string literal not displayed */
S3SecretKey *string `` /* 138-byte string literal not displayed */
S3SessionToken *string `` /* 135-byte string literal not displayed */
S3Region string `json:"s3_region,omitempty" yaml:"s3_region,omitempty" jsonschema:"description=S3 region,default=us-east-1"`
S3UsePathStyle *bool `` /* 131-byte string literal not displayed */
S3UseSsl *bool `json:"s3_use_ssl,omitempty" yaml:"s3_use_ssl,omitempty" jsonschema:"description=Use SSL for S3 connections,default=true"`
S3Prefix *string `json:"s3_prefix,omitempty" yaml:"s3_prefix,omitempty" jsonschema:"description=S3 path prefix for backups"`
GsPrefix *string `json:"gs_prefix,omitempty" yaml:"gs_prefix,omitempty" jsonschema:"description=Google Cloud Storage path prefix"`
GsServiceAccountKey *string `` /* 142-byte string literal not displayed */
AzPrefix *string `json:"az_prefix,omitempty" yaml:"az_prefix,omitempty" jsonschema:"description=Azure Storage path prefix"`
AzAccountName *string `json:"az_account_name,omitempty" yaml:"az_account_name,omitempty" jsonschema:"description=Azure Storage account name"`
AzAccountKey *string `json:"az_account_key,omitempty" yaml:"az_account_key,omitempty" jsonschema:"description=Azure Storage account key"`
FilePrefix *string `json:"file_prefix,omitempty" yaml:"file_prefix,omitempty" jsonschema:"description=Local filesystem path prefix for backups"`
CompressionMethod *string `` /* 213-byte string literal not displayed */
CompressionType *string `` /* 173-byte string literal not displayed */
DiskRateLimitBps *int `` /* 148-byte string literal not displayed */
NetworkRateLimitBps *int `` /* 153-byte string literal not displayed */
BackupSchedule string `json:"backup_schedule,omitempty" yaml:"backup_schedule,omitempty" jsonschema:"description=Backup schedule in cron format"`
BackupRetainCount int `` /* 146-byte string literal not displayed */
RetentionPolicy *string `json:"retention_policy,omitempty" yaml:"retention_policy,omitempty" jsonschema:"description=Retention policy configuration"`
PostgresqlDataDir string `` /* 162-byte string literal not displayed */
PostgresqlPassword *string `` /* 137-byte string literal not displayed */
StreamCreateCommand *string `` /* 137-byte string literal not displayed */
StreamRestoreCommand *string `` /* 145-byte string literal not displayed */
}
WalgConf represents WAL-G backup configuration
type WalgStatus ¶
type WalgStatus struct {
Enabled bool `json:"enabled"`
Healthy bool `json:"healthy"`
CheckTime time.Time `json:"check_time"`
Storage string `json:"storage"`
Schedule string `json:"schedule"`
Retention int `json:"retention"`
BackupCount int `json:"backup_count"`
LastBackup *time.Time `json:"last_backup,omitempty"`
Message string `json:"message,omitempty"`
Error string `json:"error,omitempty"`
}
WalgStatus represents the status of a WAL-G service