Documentation
¶
Index ¶
- func DatabaseAlreadyExists(dataDir string) bool
- func ValidateMinimumEnv(env *DockerEnv, databaseExists bool) error
- func WrappedError(err error) exec.WrapperFunc
- type Checkpoint
- type DataDirFileInfo
- type DataDirTree
- type DockerEnv
- type ExtensionInfo
- type ExtensionStatus
- type HealthServer
- type InitDBOptions
- type PGVersion
- type Postgres
- func (p *Postgres) Backup() error
- func (p *Postgres) CreateDatabase(name string) error
- func (p *Postgres) DescribeConfig() ([]schemas.Param, error)
- func (p *Postgres) DetectVersion() (int, error)
- func (p *Postgres) Exists() bool
- func (p *Postgres) GetConnection() (*sql.DB, error)
- func (p *Postgres) GetConnectionString() string
- func (p *Postgres) GetControlData() (*config.ControlData, error)
- func (p *Postgres) GetCurrentConf() (config.ConfSettings, error)
- func (p *Postgres) GetFullVersion() string
- func (p *Postgres) GetStderr() string
- func (p *Postgres) GetStdout() string
- func (p *Postgres) GetSupportedExtensions() []string
- func (p *Postgres) GetVersion() PGVersion
- func (p *Postgres) Health() error
- func (p *Postgres) Info() (*PostgresInfo, error)
- func (p *Postgres) InitDB() error
- func (p *Postgres) InitDBWithOptions(opts InitDBOptions) error
- func (p *Postgres) InstallExtensions(extensions []string) error
- func (p *Postgres) IsRemote() bool
- func (p *Postgres) IsRunning() bool
- func (p *Postgres) ListAvailableExtensions() ([]ExtensionInfo, error)
- func (p *Postgres) ListInstalledExtensions() ([]ExtensionInfo, error)
- func (p *Postgres) Pg_ctl(args ...string) *exec.Process
- func (p *Postgres) Ping() error
- func (p *Postgres) ProcessInitScripts(initDir string) error
- func (p *Postgres) Psql(args ...string) *exec.Process
- func (p *Postgres) ResetPassword(newPassword utils.SensitiveString) error
- func (p *Postgres) SQL(sqlQuery string, args ...any) ([]map[string]interface{}, error)
- func (p *Postgres) SetupPgHBA(method string) error
- func (p *Postgres) Start() error
- func (p *Postgres) StartTempServer(opts TempServerOptions) (*exec.Process, error)
- func (p *Postgres) Stop() error
- func (p *Postgres) StopTempServer() error
- func (p *Postgres) Upgrade(targetVersion int) error
- func (p *Postgres) Validate() error
- func (p *Postgres) ValidateConfig(config []byte) error
- func (p *Postgres) WithConnection(fn func(db *sql.DB) error) error
- func (p *Postgres) WithoutAuth() *Postgres
- type PostgresInfo
- type ServiceStatus
- type TempServerOptions
- type ValidationError
- type WalInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DatabaseAlreadyExists ¶ added in v1.0.4
DatabaseAlreadyExists checks if the database has already been initialized
func ValidateMinimumEnv ¶ added in v1.0.4
ValidateMinimumEnv validates that required environment variables are set
func WrappedError ¶ added in v1.0.4
func WrappedError(err error) exec.WrapperFunc
Types ¶
type Checkpoint ¶ added in v1.0.4
type DataDirFileInfo ¶ added in v1.0.4
type DataDirFileInfo struct {
Name string `json:"name"`
Path string `json:"path"`
Size int64 `json:"size"`
MD5 string `json:"md5"`
Modified time.Time `json:"modified"`
}
func (*DataDirFileInfo) GetChildren ¶ added in v1.0.4
func (f *DataDirFileInfo) GetChildren() []api.TreeNode
GetChildren implements TreeNode interface for DataDirFileInfo
func (*DataDirFileInfo) Pretty ¶ added in v1.0.4
func (f *DataDirFileInfo) Pretty() api.Text
Pretty implements the api.Text formatting for DataDirFileInfo
type DataDirTree ¶ added in v1.0.4
type DataDirTree struct {
Label string `json:"label"`
Path string `json:"path"`
Files []DataDirFileInfo `json:"files"`
}
func (*DataDirTree) GetChildren ¶ added in v1.0.4
func (d *DataDirTree) GetChildren() []api.TreeNode
GetChildren implements TreeNode interface for DataDirTree
func (*DataDirTree) Pretty ¶ added in v1.0.4
func (d *DataDirTree) Pretty() api.Text
Pretty implements the api.Text formatting for DataDirTree
type DockerEnv ¶ added in v1.0.4
type DockerEnv struct {
User string
Password utils.SensitiveString
Database string
InitDBArgs string
WALDir string
HostAuthMethod string
}
func SetupDockerEnv ¶ added in v1.0.4
SetupDockerEnv loads Docker-compatible environment variables
type ExtensionStatus ¶
type ExtensionStatus struct {
Name string `json:"name"`
SQLName string `json:"sql_name"`
Installed bool `json:"installed"`
Version string `json:"version,omitempty"`
Required bool `json:"required"`
Available bool `json:"available"`
Error string `json:"error,omitempty"`
}
ExtensionStatus represents the status of a PostgreSQL extension
type HealthServer ¶
type HealthServer struct {
Port int
ConfigDir string
SystemInfo *sysinfo.SystemInfo
TunedParams *pgtune.TunedParameters
DBType string
MaxConn int
// Service configurations
PostgresConfig *pkg.PostgresConf
PgBouncerConfig *pkg.PgBouncerConf
PostgRESTConfig *pkg.PostgrestConf
WalgConfig *pkg.WalgConf
// contains filtered or unexported fields
}
HealthServer provides health check and configuration endpoints
func NewHealthServer ¶
func NewHealthServer(port int, configDir string) *HealthServer
NewHealthServer creates a new health check server
func (*HealthServer) LoadServiceConfigs ¶
func (s *HealthServer) LoadServiceConfigs()
LoadServiceConfigs loads and hydrates service configurations with defaults
func (*HealthServer) SaveConfigsToDir ¶
func (s *HealthServer) SaveConfigsToDir(dir string) error
SaveConfigsToDir saves all configuration files to the specified directory
func (*HealthServer) SetConfiguration ¶
func (s *HealthServer) SetConfiguration(maxConn int, dbType string, tunedParams *pgtune.TunedParameters)
SetConfiguration sets the tuning configuration for the server
func (*HealthServer) Start ¶
func (s *HealthServer) Start() error
Start starts the health check server
type InitDBOptions ¶ added in v1.0.4
type Postgres ¶
type Postgres struct {
Config *pkg.PostgresConf
DataDir string
BinDir string // Auto-resolved based on detected version
Locale string
Encoding string
Host string
Port int
Username string
Password utils.SensitiveString
Database string
DryRun bool
// contains filtered or unexported fields
}
func NewPostgres ¶
func NewPostgres(config *pkg.PostgresConf, dataDir string) *Postgres
NewPostgres creates a new PostgreSQL service instance
func NewRemotePostgres ¶ added in v1.0.4
func (*Postgres) CreateDatabase ¶ added in v1.0.4
func (*Postgres) DescribeConfig ¶
DescribeConfig executes `postgres --describe-config` and returns parsed parameters
func (*Postgres) DetectVersion ¶
DetectVersion reads the PostgreSQL version from the data directory
func (*Postgres) GetConnection ¶ added in v1.0.4
func (*Postgres) GetConnectionString ¶ added in v1.0.4
func (*Postgres) GetControlData ¶ added in v1.0.4
func (p *Postgres) GetControlData() (*config.ControlData, error)
GetControlData executes `pg_controldata` and returns parsed control data
func (*Postgres) GetCurrentConf ¶ added in v1.0.4
func (p *Postgres) GetCurrentConf() (config.ConfSettings, error)
GetCurrentConf queries the running PostgreSQL instance for current configuration
func (*Postgres) GetFullVersion ¶ added in v1.0.4
GetFullVersion returns the full PostgreSQL version string Example: "PostgreSQL 17.5 (Debian 17.5-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by..."
func (*Postgres) GetSupportedExtensions ¶
GetSupportedExtensions returns the list of well-known supported extensions
func (*Postgres) GetVersion ¶
func (*Postgres) Info ¶ added in v1.0.4
func (p *Postgres) Info() (*PostgresInfo, error)
func (*Postgres) InitDBWithOptions ¶ added in v1.0.4
func (p *Postgres) InitDBWithOptions(opts InitDBOptions) error
func (*Postgres) InstallExtensions ¶
InstallExtensions installs the specified PostgreSQL extensions
func (*Postgres) ListAvailableExtensions ¶
func (p *Postgres) ListAvailableExtensions() ([]ExtensionInfo, error)
ListAvailableExtensions returns a list of available PostgreSQL extensions
func (*Postgres) ListInstalledExtensions ¶
func (p *Postgres) ListInstalledExtensions() ([]ExtensionInfo, error)
ListInstalledExtensions returns a list of installed PostgreSQL extensions
func (*Postgres) ProcessInitScripts ¶ added in v1.0.4
ProcessInitScripts processes initialization scripts from /docker-entrypoint-initdb.d/ Supports .sh, .sql, .sql.gz, .sql.xz, .sql.zst files
func (*Postgres) ResetPassword ¶
func (p *Postgres) ResetPassword(newPassword utils.SensitiveString) error
ResetPassword resets the PostgreSQL superuser password using a temporary server instance
func (*Postgres) SetupPgHBA ¶ added in v1.0.4
SetupPgHBA configures pg_hba.conf for host authentication Allows trust authentication from localhost and password authentication from external hosts
func (*Postgres) StartTempServer ¶ added in v1.0.4
func (p *Postgres) StartTempServer(opts TempServerOptions) (*exec.Process, error)
StartTempServer starts a temporary PostgreSQL server for initialization tasks If UnixSocketOnly is true, uses listen_addresses=” for Unix socket-only mode
func (*Postgres) StopTempServer ¶ added in v1.0.4
StopTempServer stops a temporary PostgreSQL server
func (*Postgres) ValidateConfig ¶ added in v1.0.4
Validate validates a PostgreSQL configuration file using the postgres binary
func (*Postgres) WithConnection ¶ added in v1.0.4
func (*Postgres) WithoutAuth ¶ added in v1.0.4
type PostgresInfo ¶ added in v1.0.4
type PostgresInfo struct {
// e.g. 16 or 17
VersionNumber int `json:"version"`
VersionInfo string `json:"version_info"`
Running bool `json:"running"`
DataDirectory string `json:"data_dir"`
BinDir string `json:"bin_dir"`
ListenAddress string `json:"listen_address"`
Port int `json:"port"`
System sysinfo.SystemInfo `json:"system,omitempty"`
// Configuration from disk (postgresql.conf + postgres.auto.conf)
Files map[string]config.Conf `json:"conf_files,omitempty"`
MergedConf config.Conf `json:"merged_conf,omitempty"`
// Runtime configuration from running instance (only populated if running)
RuntimeConf config.Conf `json:"runtime_conf,omitempty"`
// Size of folders on disk
DataSize int64 `json:"data_size" pretty:"format=bytes"`
// Size of all DBs combined
DBSize int64 `json:"db_size" pretty:"format=bytes"`
// Data directory files tree
DataDir string `json:"data_dir_tree,omitempty" `
// pg_controldata
ClusterState string `json:"cluster_state"`
SystemIdentifier string `json:"system_identifier"`
FullVersion string `json:"full_version"`
WalInfo WalInfo `json:"wal_info,omitempty"`
Checkpoint Checkpoint `json:"checkpoint,omitempty"`
}
type ServiceStatus ¶
type ServiceStatus struct {
Name string `json:"name"`
Status string `json:"status"` // "running", "stopped", "unknown"
Port int `json:"port,omitempty"`
PortOpen bool `json:"port_open"`
Enabled bool `json:"enabled"`
Uptime string `json:"uptime,omitempty"`
RestartCount int `json:"restart_count,omitempty"`
Details string `json:"details,omitempty"`
}
ServiceStatus represents the status of a service
type TempServerOptions ¶ added in v1.0.4
type ValidationError ¶
type ValidationError = pkg.ValidationError