server

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExtensionInfo

type ExtensionInfo = pkg.ExtensionInfo

Use types from pkg package

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      sysinfo.DBType
	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) ConfigFromFile

func (s *HealthServer) ConfigFromFile(maxConn int, dbType sysinfo.DBType) error

ConfigFromFile loads configuration from files in the config directory

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 sysinfo.DBType, 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

func (*HealthServer) Stop

func (s *HealthServer) Stop(ctx context.Context) error

Stop stops the health check server

type PGVersion

type PGVersion = pkg.PgVersion

type Postgres

type Postgres struct {
	Config  *pkg.PostgresConf
	DataDir string
	BinDir  string // Auto-resolved based on detected version
	// contains filtered or unexported fields
}

func NewPostgres

func NewPostgres(config *pkg.PostgresConf, dataDir string) *Postgres

NewPostgres creates a new PostgreSQL service instance

func (*Postgres) Backup

func (p *Postgres) Backup() error

func (*Postgres) DescribeConfig

func (p *Postgres) DescribeConfig() ([]schemas.Param, error)

DescribeConfig executes `postgres --describe-config` and returns parsed parameters

func (*Postgres) DetectVersion

func (p *Postgres) DetectVersion() (int, error)

DetectVersion reads the PostgreSQL version from the data directory

func (*Postgres) Exists

func (p *Postgres) Exists() bool

func (*Postgres) GetStderr

func (p *Postgres) GetStderr() string

func (*Postgres) GetStdout

func (p *Postgres) GetStdout() string

func (*Postgres) GetSupportedExtensions

func (p *Postgres) GetSupportedExtensions() []string

GetSupportedExtensions returns the list of well-known supported extensions

func (*Postgres) GetVersion

func (p *Postgres) GetVersion() PGVersion

func (*Postgres) Health

func (p *Postgres) Health() error

Health performs a comprehensive health check of the PostgreSQL service

func (*Postgres) InitDB

func (p *Postgres) InitDB() error

func (*Postgres) InstallExtensions

func (p *Postgres) InstallExtensions(extensions []string) error

InstallExtensions installs the specified PostgreSQL extensions

func (*Postgres) IsRunning

func (p *Postgres) IsRunning() bool

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) ResetPassword

func (p *Postgres) ResetPassword(newPassword utils.SensitiveString) error

ResetPassword resets the PostgreSQL superuser password using a temporary server instance

func (*Postgres) SQL

func (p *Postgres) SQL(sqlQuery string) ([]map[string]interface{}, error)

func (*Postgres) Start

func (p *Postgres) Start() error

func (*Postgres) Stop

func (p *Postgres) Stop() error

func (*Postgres) Upgrade

func (p *Postgres) Upgrade(targetVersion int) error

func (*Postgres) Validate

func (p *Postgres) Validate(config []byte) error

Validate validates a PostgreSQL configuration file using the postgres binary

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 ValidationError

type ValidationError = pkg.ValidationError

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL