systemd

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: PostgreSQL Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const ResourceTypePatroniConfig resource.Type = "systemd.patroni_config"
View Source
const ResourceTypePgBackRestRestore resource.Type = "systemd.pgbackrest_restore"
View Source
const ResourceTypeUnit resource.Type = "systemd.unit"

Variables

View Source
var ErrUnitNotFound = errors.New("unit does not exist")

Functions

func InstallWantedByOption

func InstallWantedByOption(value ...string) *unit.UnitOption

func InstalledPostgresCmp

func InstalledPostgresCmp(a, b *InstalledPostgres) int

func PackageCmp

func PackageCmp(a, b *InstalledPackage) int

func PatroniConfigIdentifier

func PatroniConfigIdentifier(instanceID string) resource.Identifier

func PatroniUnitOptions

func PatroniUnitOptions(
	paths database.InstancePaths,
	pgBinPath string,
	cpus float64,
	memoryBytes uint64,
) []*unit.UnitOption

func PgBackRestRestoreResourceIdentifier

func PgBackRestRestoreResourceIdentifier(instanceID string) resource.Identifier

func Provide

func Provide(i *do.Injector)

func RegisterResourceTypes

func RegisterResourceTypes(registry *resource.Registry)

func ServiceCPUQuotaOption

func ServiceCPUQuotaOption(cpus float64) *unit.UnitOption

func ServiceEnvironmentOption

func ServiceEnvironmentOption(name, value string) *unit.UnitOption

func ServiceExecReloadOption

func ServiceExecReloadOption(value string) *unit.UnitOption

func ServiceExecStartOption

func ServiceExecStartOption(value string) *unit.UnitOption

func ServiceKillModeOption

func ServiceKillModeOption(value ServiceKillMode) *unit.UnitOption

func ServiceMemoryMaxOption

func ServiceMemoryMaxOption(memoryBytes uint64) *unit.UnitOption

func ServiceRestartOption

func ServiceRestartOption(value ServiceRestart) *unit.UnitOption

func ServiceTimeoutSecOption

func ServiceTimeoutSecOption(value int) *unit.UnitOption

func ServiceTypeOption

func ServiceTypeOption(value ServiceType) *unit.UnitOption

func ServiceUserOption

func ServiceUserOption(value string) *unit.UnitOption

func UnitAfterOption

func UnitAfterOption(values ...string) *unit.UnitOption

func UnitResourceIdentifier

func UnitResourceIdentifier(name, databaseID, hostID string) resource.Identifier

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(loggerFactory *logging.Factory) *Client

func (*Client) DisableUnit

func (c *Client) DisableUnit(ctx context.Context, path string) error

func (*Client) EnableUnit

func (c *Client) EnableUnit(ctx context.Context, name string) error

func (*Client) GetMainPID

func (c *Client) GetMainPID(ctx context.Context, name string) (int, error)

func (*Client) Reload

func (c *Client) Reload(ctx context.Context) error

func (*Client) ReloadOrRestartUnit

func (c *Client) ReloadOrRestartUnit(ctx context.Context, name string) error

func (*Client) ReloadUnit

func (c *Client) ReloadUnit(ctx context.Context, name string) error

func (*Client) Shutdown

func (c *Client) Shutdown() error

func (*Client) Start

func (c *Client) Start(ctx context.Context) error

func (*Client) StartUnit

func (c *Client) StartUnit(ctx context.Context, name string) error

func (*Client) StopUnit

func (c *Client) StopUnit(ctx context.Context, name string, wait bool) error

func (*Client) UnitExists

func (c *Client) UnitExists(ctx context.Context, name string) error

type Dnf

type Dnf struct{}

func (*Dnf) BinDir

func (d *Dnf) BinDir(pgMajor string) string

func (*Dnf) InstalledPostgresVersions

func (d *Dnf) InstalledPostgresVersions(ctx context.Context) ([]*InstalledPostgres, error)

func (*Dnf) InstanceDataBaseDir

func (d *Dnf) InstanceDataBaseDir(pgMajor string) string

type InstallSection

type InstallSection struct {
	WantedBy []string
}

func (InstallSection) Options

func (s InstallSection) Options() []*unit.UnitOption

type InstalledPackage

type InstalledPackage struct {
	PostgresMajor string
	Version       *ds.Version
	Name          string
}

func InstalledPostgresPackage

func InstalledPostgresPackage(pkg, ver string) (*InstalledPackage, error)

func InstalledSpockPackage

func InstalledSpockPackage(pkg, ver string) (*InstalledPackage, error)

type InstalledPostgres

type InstalledPostgres struct {
	Postgres *InstalledPackage
	Spock    []*InstalledPackage
}

type Orchestrator

type Orchestrator struct {
	// contains filtered or unexported fields
}

func NewOrchestrator

func NewOrchestrator(
	cfg config.Config,
	loggerFactory *logging.Factory,
	client *Client,
	packageManager PackageManager,
) (*Orchestrator, error)

func (*Orchestrator) CreatePgBackRestBackup

func (o *Orchestrator) CreatePgBackRestBackup(ctx context.Context, w io.Writer, spec *database.InstanceSpec, options *pgbackrest.BackupOptions) error

func (*Orchestrator) ExecuteInstanceCommand

func (o *Orchestrator) ExecuteInstanceCommand(ctx context.Context, w io.Writer, databaseID, instanceID string, args ...string) error

func (*Orchestrator) GenerateInstanceResources

func (o *Orchestrator) GenerateInstanceResources(spec *database.InstanceSpec, scripts database.Scripts) (*database.InstanceResources, error)

func (*Orchestrator) GenerateInstanceRestoreResources

func (o *Orchestrator) GenerateInstanceRestoreResources(spec *database.InstanceSpec, taskID uuid.UUID) (*database.InstanceResources, error)

func (*Orchestrator) GenerateServiceInstanceResources

func (o *Orchestrator) GenerateServiceInstanceResources(spec *database.ServiceInstanceSpec) (*database.ServiceInstanceResources, error)

func (*Orchestrator) GetInstanceConnectionInfo

func (o *Orchestrator) GetInstanceConnectionInfo(ctx context.Context,
	databaseID, instanceID string,
	postgresPort, patroniPort *int,
	pgEdgeVersion *ds.PgEdgeVersion,
) (*database.ConnectionInfo, error)

func (*Orchestrator) GetServiceInstanceStatus

func (o *Orchestrator) GetServiceInstanceStatus(ctx context.Context, serviceInstanceID string) (*database.ServiceInstanceStatus, error)

func (*Orchestrator) InstancePaths

func (o *Orchestrator) InstancePaths(pgVersion *ds.Version, instanceID string) (database.InstancePaths, error)

func (*Orchestrator) NodeDSN

func (o *Orchestrator) NodeDSN(ctx context.Context, rc *resource.Context, nodeName string, fromInstanceID string, dbName string) (*postgres.DSN, error)

func (*Orchestrator) PopulateHost

func (o *Orchestrator) PopulateHost(ctx context.Context, h *host.Host) error

func (*Orchestrator) PopulateHostStatus

func (o *Orchestrator) PopulateHostStatus(ctx context.Context, h *host.HostStatus) error

func (*Orchestrator) Start

func (o *Orchestrator) Start(ctx context.Context) error

func (*Orchestrator) StartInstance

func (o *Orchestrator) StartInstance(ctx context.Context, instanceID string) error

func (*Orchestrator) StopInstance

func (o *Orchestrator) StopInstance(ctx context.Context, instanceID string) error

func (*Orchestrator) ValidateInstanceSpecs

func (o *Orchestrator) ValidateInstanceSpecs(_ context.Context, changes []*database.InstanceSpecChange) ([]*database.ValidationResult, error)

func (*Orchestrator) WorkerQueues

func (o *Orchestrator) WorkerQueues() ([]workflow.Queue, error)

type PackageManager

type PackageManager interface {
	InstalledPostgresVersions(ctx context.Context) ([]*InstalledPostgres, error)
	InstanceDataBaseDir(pgMajor string) string
	BinDir(pgMajor string) string
}

type PatroniConfig

type PatroniConfig struct {
	DatabaseID string                `json:"database_id"`
	Base       *common.PatroniConfig `json:"base"`
	AllHostIDs []string              `json:"all_host_ids"`
}

func (*PatroniConfig) Create

func (c *PatroniConfig) Create(ctx context.Context, rc *resource.Context) error

func (*PatroniConfig) Delete

func (c *PatroniConfig) Delete(ctx context.Context, rc *resource.Context) error

func (*PatroniConfig) Dependencies

func (c *PatroniConfig) Dependencies() []resource.Identifier

func (*PatroniConfig) DiffIgnore

func (c *PatroniConfig) DiffIgnore() []string

func (*PatroniConfig) Executor

func (c *PatroniConfig) Executor() resource.Executor

func (*PatroniConfig) Identifier

func (c *PatroniConfig) Identifier() resource.Identifier

func (*PatroniConfig) Refresh

func (c *PatroniConfig) Refresh(ctx context.Context, rc *resource.Context) error

func (*PatroniConfig) ResourceVersion

func (c *PatroniConfig) ResourceVersion() string

func (*PatroniConfig) TypeDependencies

func (c *PatroniConfig) TypeDependencies() []resource.Type

func (*PatroniConfig) Update

func (c *PatroniConfig) Update(ctx context.Context, rc *resource.Context) error

type PgBackRestRestore

type PgBackRestRestore struct {
	DatabaseID     string                 `json:"database_id"`
	HostID         string                 `json:"host_id"`
	InstanceID     string                 `json:"instance_id"`
	TaskID         uuid.UUID              `json:"task_id"`
	NodeName       string                 `json:"node_name"`
	Paths          database.InstancePaths `json:"paths"`
	RestoreOptions map[string]string      `json:"restore_options"`
}

func (*PgBackRestRestore) Create

func (p *PgBackRestRestore) Create(ctx context.Context, rc *resource.Context) error

func (*PgBackRestRestore) Delete

func (p *PgBackRestRestore) Delete(ctx context.Context, rc *resource.Context) error

func (*PgBackRestRestore) Dependencies

func (p *PgBackRestRestore) Dependencies() []resource.Identifier

func (*PgBackRestRestore) DiffIgnore

func (p *PgBackRestRestore) DiffIgnore() []string

func (*PgBackRestRestore) Executor

func (p *PgBackRestRestore) Executor() resource.Executor

func (*PgBackRestRestore) Identifier

func (p *PgBackRestRestore) Identifier() resource.Identifier

func (*PgBackRestRestore) Refresh

func (p *PgBackRestRestore) Refresh(ctx context.Context, rc *resource.Context) error

func (*PgBackRestRestore) ResourceVersion

func (p *PgBackRestRestore) ResourceVersion() string

func (*PgBackRestRestore) TypeDependencies

func (p *PgBackRestRestore) TypeDependencies() []resource.Type

func (*PgBackRestRestore) Update

func (p *PgBackRestRestore) Update(ctx context.Context, rc *resource.Context) error

type ServiceKillMode

type ServiceKillMode string
const (
	ServiceKillModeControlGroup ServiceKillMode = "control-group"
	ServiceKillModeMixed        ServiceKillMode = "mixed"
	ServiceKillModeProcess      ServiceKillMode = "process"
	ServiceKillModeNone         ServiceKillMode = "none"
)

func (ServiceKillMode) String

func (s ServiceKillMode) String() string

type ServiceRestart

type ServiceRestart string
const (
	ServiceRestartNo         ServiceRestart = "no"
	ServiceRestartAlways     ServiceRestart = "always"
	ServiceRestartOnSuccess  ServiceRestart = "on-success"
	ServiceRestartOnFailure  ServiceRestart = "on-failure"
	ServiceRestartOnAbnormal ServiceRestart = "on-abnormal"
	ServiceRestartOnAbort    ServiceRestart = "on-abort"
	ServiceRestartOnWatchdog ServiceRestart = "on-watchdog"
)

func (ServiceRestart) String

func (s ServiceRestart) String() string

type ServiceSection

type ServiceSection struct {
	Type        ServiceType
	User        string
	ExecStart   string
	ExecReload  string
	KillMode    ServiceKillMode
	TimeoutSec  int
	CPUs        float64
	MemoryBytes uint64
	Restart     ServiceRestart
	Environment map[string]string
}

func (ServiceSection) Options

func (s ServiceSection) Options() []*unit.UnitOption

type ServiceType

type ServiceType string
const (
	ServiceTypeSimple       ServiceType = "simple"
	ServiceTypeExec         ServiceType = "exec"
	ServiceTypeForking      ServiceType = "forking"
	ServiceTypeOneShot      ServiceType = "oneshot"
	ServiceTypeNotify       ServiceType = "notify"
	ServiceTypeDBus         ServiceType = "dbus"
	ServiceTypeIdle         ServiceType = "idle"
	ServiceTypeNotifyReload ServiceType = "notify-reload"
)

func (ServiceType) String

func (s ServiceType) String() string

type UnitFile

type UnitFile struct {
	Unit    UnitSection
	Service ServiceSection
	Install InstallSection
}

func (UnitFile) Options

func (f UnitFile) Options() []*unit.UnitOption

type UnitResource

type UnitResource struct {
	DatabaseID        string                `json:"database_id"`
	HostID            string                `json:"host_id"`
	Name              string                `json:"name"`
	Options           []*unit.UnitOption    `json:"options"`
	ExtraDependencies []resource.Identifier `json:"extra_dependencies"`
}

func (*UnitResource) Create

func (r *UnitResource) Create(ctx context.Context, rc *resource.Context) error

func (*UnitResource) Delete

func (r *UnitResource) Delete(ctx context.Context, rc *resource.Context) error

func (*UnitResource) Dependencies

func (r *UnitResource) Dependencies() []resource.Identifier

func (*UnitResource) DiffIgnore

func (r *UnitResource) DiffIgnore() []string

func (*UnitResource) Executor

func (r *UnitResource) Executor() resource.Executor

func (*UnitResource) Identifier

func (r *UnitResource) Identifier() resource.Identifier

func (*UnitResource) Refresh

func (r *UnitResource) Refresh(ctx context.Context, rc *resource.Context) error

func (*UnitResource) ResourceVersion

func (r *UnitResource) ResourceVersion() string

func (*UnitResource) TypeDependencies

func (r *UnitResource) TypeDependencies() []resource.Type

func (*UnitResource) Update

func (r *UnitResource) Update(ctx context.Context, rc *resource.Context) error

type UnitSection

type UnitSection struct {
	After []string
}

func (UnitSection) Options

func (u UnitSection) Options() []*unit.UnitOption

Jump to

Keyboard shortcuts

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