operations

package
v0.1.39 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectToRunningInstance

func ConnectToRunningInstance(ctx context.Context, deps *Dependencies, instanceName string, opts ...ConnectOptions) (*pgx.Conn, error)

ConnectToRunningInstance connects to a PostgreSQL instance, ensuring it's running first

func GetActiveOffsiteSettingsDecrypted

func GetActiveOffsiteSettingsDecrypted(deps *Dependencies) (*offsite.OffsiteSettings, error)

GetActiveOffsiteSettingsDecrypted returns the active offsite settings with the SecretAccessKey decrypted, ready to hand to an S3 client. It returns a copy so the stored ciphertext is never mutated, and never lets the encrypted secret reach an S3 auth path (the bug that left cron remote cleanup unable to delete). For EC2 IAM-role mode (or an empty secret) the secret is left empty. Returns (nil, nil) when no offsite configuration is active.

func OffsiteApply

func OffsiteApply(deps *Dependencies, params *OffsiteApplyParams) error

func OffsiteLogs

func OffsiteLogs(deps *Dependencies, params *OffsiteLogsParams) ([]offsite.OffsiteLog, error)

func OffsiteRemove

func OffsiteRemove(deps *Dependencies) error

func StreamInstanceLogs

func StreamInstanceLogs(ctx context.Context, deps *Dependencies, params GetLogsParams, w io.Writer) error

StreamInstanceLogs streams container logs to w until ctx is cancelled or the container stops.

func TestPostgreSQLConnectivityWithPassword

func TestPostgreSQLConnectivityWithPassword(ctx context.Context, port int, password string) error

TestPostgreSQLConnectivityWithPassword tests PostgreSQL connectivity with a custom password

Types

type AddDatabaseUserParams

type AddDatabaseUserParams struct {
	InstanceName string
	DatabaseName string
	Username     string
	ReadOnly     bool
	Owner        bool // Make user the owner of the database
}

type AddDatabaseUserResult

type AddDatabaseUserResult struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Database string `json:"database"`
	ReadOnly bool   `json:"readOnly"`
	Message  string `json:"message"`
}

type BackupRDBMSParams

type BackupRDBMSParams struct {
	Name      string
	BackupDir string
	Comment   string // Optional comment for the backup
}

BackupRDBMSParams contains parameters for backing up an RDBMS instance

type BackupRDBMSResult

type BackupRDBMSResult struct {
	BackupID   int
	BackupPath string
	Size       int64
	Timestamp  time.Time
}

BackupRDBMSResult contains the result of backing up an RDBMS instance

func BackupRDBMS

func BackupRDBMS(ctx context.Context, deps *Dependencies, params *BackupRDBMSParams) (*BackupRDBMSResult, error)

BackupRDBMS creates a backup of an RDBMS instance

type ConnectOptions

type ConnectOptions struct {
	Database string
}

ConnectOptions allows specifying optional parameters for database connections

type ConsistencyCheckOp

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

ConsistencyCheckOp validates RDBMS instance consistency

func NewConsistencyCheckOp

func NewConsistencyCheckOp(deps *Dependencies, instance *instances.RDBMSInstance) *ConsistencyCheckOp

func (*ConsistencyCheckOp) Execute

func (op *ConsistencyCheckOp) Execute(ctx context.Context) error

func (*ConsistencyCheckOp) GetInstance

func (op *ConsistencyCheckOp) GetInstance() *instances.RDBMSInstance

func (*ConsistencyCheckOp) GetStatus

func (op *ConsistencyCheckOp) GetStatus() *ConsistencyStatus

func (*ConsistencyCheckOp) Name

func (op *ConsistencyCheckOp) Name() string

func (*ConsistencyCheckOp) Type

func (op *ConsistencyCheckOp) Type() OpType

type ConsistencyStatus

type ConsistencyStatus struct {
	ContainerExists  bool
	ContainerRunning bool
	PostgreSQLReady  bool
	OverallHealthy   bool
	Issues           []string
}

ConsistencyStatus represents the health status of an RDBMS instance

type CreateDatabaseParams

type CreateDatabaseParams struct {
	InstanceName string
	DatabaseName string
}

type CreateDatabaseResult

type CreateDatabaseResult struct {
	DatabaseName string `json:"databaseName"`
	Message      string `json:"message"`
}

func CreateDatabase

func CreateDatabase(ctx context.Context, deps *Dependencies, params CreateDatabaseParams) (*CreateDatabaseResult, error)

type CreateRDBMSOp

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

CreateRDBMSOp creates a new RDBMS instance

func NewCreateRDBMSOp

func NewCreateRDBMSOp(deps *Dependencies, params CreateRDBMSParams) *CreateRDBMSOp

NewCreateRDBMSOp creates a new create RDBMS operation

func (*CreateRDBMSOp) Execute

func (op *CreateRDBMSOp) Execute(ctx context.Context) error

func (*CreateRDBMSOp) GetResult

func (op *CreateRDBMSOp) GetResult() *CreateRDBMSResult

GetResult returns the operation result

func (*CreateRDBMSOp) Name

func (op *CreateRDBMSOp) Name() string

func (*CreateRDBMSOp) Type

func (op *CreateRDBMSOp) Type() OpType

type CreateRDBMSParams

type CreateRDBMSParams struct {
	Name           string
	Version        string
	Image          string
	Port           int
	CPUCores       int
	RAMMB          int
	ParameterGroup string
}

CreateRDBMSParams contains parameters for creating an RDBMS instance

type CreateRDBMSResult

type CreateRDBMSResult struct {
	Instance *instances.RDBMSInstance
	Password string // Plaintext password for initial response
}

CreateRDBMSResult contains the result of creating an RDBMS instance

type CronBackupCreateOp

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

func NewCronBackupCreateOp

func NewCronBackupCreateOp(deps *Dependencies, instanceName string, utcHour, cleanupLocalDays, cleanupRemoteDays int) *CronBackupCreateOp

func (*CronBackupCreateOp) Execute

func (op *CronBackupCreateOp) Execute(ctx context.Context) error

func (*CronBackupCreateOp) GetResult

func (op *CronBackupCreateOp) GetResult() *cron.CronPlan

func (*CronBackupCreateOp) Name

func (op *CronBackupCreateOp) Name() string

func (*CronBackupCreateOp) Type

func (op *CronBackupCreateOp) Type() OpType

type CronBackupDeleteOp

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

func NewCronBackupDeleteOp

func NewCronBackupDeleteOp(deps *Dependencies, instanceName string) *CronBackupDeleteOp

func (*CronBackupDeleteOp) Execute

func (op *CronBackupDeleteOp) Execute(ctx context.Context) error

func (*CronBackupDeleteOp) Name

func (op *CronBackupDeleteOp) Name() string

func (*CronBackupDeleteOp) Type

func (op *CronBackupDeleteOp) Type() OpType

type CronBackupListOp

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

func NewCronBackupListOp

func NewCronBackupListOp(deps *Dependencies) *CronBackupListOp

func (*CronBackupListOp) Execute

func (op *CronBackupListOp) Execute(ctx context.Context) error

func (*CronBackupListOp) GetResult

func (op *CronBackupListOp) GetResult() []*cron.CronPlan

func (*CronBackupListOp) Name

func (op *CronBackupListOp) Name() string

func (*CronBackupListOp) Type

func (op *CronBackupListOp) Type() OpType

type CronTaskOp

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

func NewCronTaskOp

func NewCronTaskOp(deps *Dependencies, instanceName string) *CronTaskOp

func (*CronTaskOp) Execute

func (op *CronTaskOp) Execute(ctx context.Context) error

func (*CronTaskOp) Name

func (op *CronTaskOp) Name() string

func (*CronTaskOp) Type

func (op *CronTaskOp) Type() OpType

type DatabaseInfo

type DatabaseInfo struct {
	Name      string    `json:"name"`
	Owner     string    `json:"owner"`
	Encoding  string    `json:"encoding"`
	Size      string    `json:"size"`
	CreatedAt time.Time `json:"createdAt,omitzero"`
}

type DatabaseMeta

type DatabaseMeta struct {
	Name        string `json:"name"`
	Owner       string `json:"owner"`
	Encoding    string `json:"encoding"`
	Collate     string `json:"collate"`
	Ctype       string `json:"ctype"`
	LocProvider string `json:"locProvider"` // "c" (libc), "i" (icu), "b" (builtin); "c" assumed pre-PG15
}

DatabaseMeta captures the attributes needed to faithfully recreate a database (its encoding/collation and owner). It is written into the backup archive at backup time and consumed by restore and major-upgrade.

type DeleteDatabaseUserParams

type DeleteDatabaseUserParams struct {
	InstanceName string
	Username     string
}

type DeleteDatabaseUserResult

type DeleteDatabaseUserResult struct {
	Username string `json:"username"`
	Message  string `json:"message"`
}

type DeleteRDBMSOp

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

DeleteRDBMSOp deletes an RDBMS instance

func NewDeleteRDBMSOp

func NewDeleteRDBMSOp(deps *Dependencies, params DeleteRDBMSParams) *DeleteRDBMSOp

func (*DeleteRDBMSOp) Execute

func (op *DeleteRDBMSOp) Execute(ctx context.Context) error

func (*DeleteRDBMSOp) Name

func (op *DeleteRDBMSOp) Name() string

func (*DeleteRDBMSOp) Type

func (op *DeleteRDBMSOp) Type() OpType

type DeleteRDBMSParams

type DeleteRDBMSParams struct {
	Name string
}

DeleteRDBMSParams contains parameters for deleting an RDBMS instance

type Dependencies

type Dependencies struct {
	Store     *store.Store
	Docker    *docker.Client
	MasterKey []byte
	DataDir   string // Added for backup operations
	BackupDir string // Added for backup operations
	Logger    *log.Logger
}

Dependencies holds all the dependencies needed by operations

type DownloadBackupParams

type DownloadBackupParams struct {
	InstanceName string
	BackupID     int
}

DownloadBackupParams contains parameters for downloading a backup from S3

type DownloadBackupResult

type DownloadBackupResult struct {
	Message  string `json:"message"`
	Location string `json:"location"`
	Size     int64  `json:"size"`
}

DownloadBackupResult contains the result of downloading a backup

func DownloadBackup

func DownloadBackup(ctx context.Context, deps *Dependencies, params DownloadBackupParams) (*DownloadBackupResult, error)

DownloadBackup downloads a backup from S3 to local storage

type Executor

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

Executor manages sequential execution of operations

func NewExecutor

func NewExecutor() *Executor

NewExecutor creates a new operation executor

func (*Executor) AddDatabaseUserOp

func (e *Executor) AddDatabaseUserOp(ctx context.Context, deps *Dependencies, params AddDatabaseUserParams) (*AddDatabaseUserResult, error)

AddDatabaseUserOp executes the add database user operation

func (*Executor) CreateDatabaseOp

func (e *Executor) CreateDatabaseOp(ctx context.Context, deps *Dependencies, params CreateDatabaseParams) (*CreateDatabaseResult, error)

CreateDatabaseOp executes the create database operation

func (*Executor) DeleteDatabaseUserOp

func (e *Executor) DeleteDatabaseUserOp(ctx context.Context, deps *Dependencies, params DeleteDatabaseUserParams) (*DeleteDatabaseUserResult, error)

DeleteDatabaseUserOp executes the delete database user operation

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, op Operation) error

Execute runs an operation, ensuring sequential execution.

Callers from HTTP handlers should pass context.Background(), not r.Context(): operations are uninterruptible by HTTP client disconnect by design — a half-aborted pg_dump, pg_restore, S3 upload, or container-create would leave debris (orphan helper containers, partial files, inconsistent state). The ctx here is only useful if a caller intentionally wires in cancellation (e.g. a future graceful-shutdown context).

func (*Executor) ExecuteAsync

func (e *Executor) ExecuteAsync(ctx context.Context, op Operation) <-chan error

ExecuteAsync runs an operation asynchronously but still sequentially

func (*Executor) ListDatabasesOp

func (e *Executor) ListDatabasesOp(ctx context.Context, deps *Dependencies, params ListDatabasesParams) (*ListDatabasesResult, error)

ListDatabasesOp executes the list databases operation

func (*Executor) ResetDatabaseUserPasswordOp

func (e *Executor) ResetDatabaseUserPasswordOp(ctx context.Context, deps *Dependencies, params ResetDatabaseUserPasswordParams) (*ResetDatabaseUserPasswordResult, error)

ResetDatabaseUserPasswordOp executes the reset database user password operation

type GetLogsParams

type GetLogsParams struct {
	InstanceName string
	Tail         string
}

GetLogsParams contains parameters for getting instance logs

type GetLogsResult

type GetLogsResult struct {
	Logs string
}

GetLogsResult contains the result of getting instance logs

func GetInstanceLogs

func GetInstanceLogs(ctx context.Context, deps *Dependencies, params GetLogsParams) (*GetLogsResult, error)

GetInstanceLogs fetches the container logs for a given instance

type GetPasswordOp

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

GetPasswordOp is an operation to get the decrypted password for an instance

func NewGetPasswordOp

func NewGetPasswordOp(deps *Dependencies, name string) *GetPasswordOp

NewGetPasswordOp creates a new operation to get password

func (*GetPasswordOp) Execute

func (op *GetPasswordOp) Execute(ctx context.Context) error

func (*GetPasswordOp) GetResult

func (op *GetPasswordOp) GetResult() *GetPasswordResult

func (*GetPasswordOp) Name

func (op *GetPasswordOp) Name() string

func (*GetPasswordOp) Type

func (op *GetPasswordOp) Type() OpType

type GetPasswordResult

type GetPasswordResult struct {
	Password string `json:"password"`
}

type GetRDBMSOp

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

GetRDBMSOp gets a single RDBMS instance

func NewGetRDBMSOp

func NewGetRDBMSOp(deps *Dependencies, name string) *GetRDBMSOp

func (*GetRDBMSOp) Execute

func (op *GetRDBMSOp) Execute(ctx context.Context) error

func (*GetRDBMSOp) GetResult

func (op *GetRDBMSOp) GetResult() *instances.RDBMSInstance

func (*GetRDBMSOp) Name

func (op *GetRDBMSOp) Name() string

func (*GetRDBMSOp) Type

func (op *GetRDBMSOp) Type() OpType

type ListBackupsParams

type ListBackupsParams struct {
	InstanceName string
}

ListBackupsParams contains parameters for listing backups

type ListBackupsResult

type ListBackupsResult struct {
	Backups []backup.BackupRecord
}

ListBackupsResult contains the result of listing backups

func ListBackups

func ListBackups(ctx context.Context, deps *Dependencies, params ListBackupsParams) (*ListBackupsResult, error)

ListBackups lists all backups for an RDBMS instance with consistency checks If InstanceName is empty, lists all backups across all instances

type ListDatabasesParams

type ListDatabasesParams struct {
	InstanceName string
}

type ListDatabasesResult

type ListDatabasesResult struct {
	Databases []DatabaseInfo `json:"databases"`
}

func ListDatabases

func ListDatabases(ctx context.Context, deps *Dependencies, params ListDatabasesParams) (*ListDatabasesResult, error)

type ListRDBMSOp

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

ListRDBMSOp lists all RDBMS instances

func NewListRDBMSOp

func NewListRDBMSOp(deps *Dependencies) *ListRDBMSOp

func (*ListRDBMSOp) Execute

func (op *ListRDBMSOp) Execute(ctx context.Context) error

func (*ListRDBMSOp) GetResult

func (op *ListRDBMSOp) GetResult() []instances.RDBMSInstance

func (*ListRDBMSOp) Name

func (op *ListRDBMSOp) Name() string

func (*ListRDBMSOp) Type

func (op *ListRDBMSOp) Type() OpType

type NotificationAddParams

type NotificationAddParams struct {
	Name   string                         `json:"name"`
	Type   notifications.NotificationType `json:"type"`
	Config json.RawMessage                `json:"config"`
}

type NotificationAddResult

type NotificationAddResult struct {
	Notification *notifications.Notification `json:"notification"`
}

type NotificationEditParams

type NotificationEditParams struct {
	Name   string          `json:"name"`
	Type   string          `json:"type"`
	Config json.RawMessage `json:"config"`
}

type NotificationEditResult

type NotificationEditResult struct {
	Notification *notifications.Notification `json:"notification"`
}

type NotificationGetParams

type NotificationGetParams struct {
	Name string `json:"name"`
}

type NotificationGetResult

type NotificationGetResult struct {
	Notification *notifications.Notification `json:"notification"`
}

type NotificationListParams

type NotificationListParams struct{}

type NotificationListResult

type NotificationListResult struct {
	Notifications []notifications.Notification `json:"notifications"`
}

type NotificationLogsParams

type NotificationLogsParams struct {
	Limit int `json:"limit"`
}

type NotificationLogsResult

type NotificationLogsResult struct {
	Logs []notifications.NotificationLog `json:"logs"`
}

type NotificationRemoveParams

type NotificationRemoveParams struct {
	Name string `json:"name"`
}

type NotificationRemoveResult

type NotificationRemoveResult struct {
	Message string `json:"message"`
}

type NotificationTestParams

type NotificationTestParams struct{}

type NotificationTestResult

type NotificationTestResult struct {
	Message string `json:"message"`
}

type OffsiteApplyParams

type OffsiteApplyParams struct {
	ConfigJSON []byte
}

type OffsiteGetResult

type OffsiteGetResult struct {
	Config offsite.OffsiteSettingsJSON `json:"config"`
}

func OffsiteGet

func OffsiteGet(deps *Dependencies) (*OffsiteGetResult, error)

type OffsiteInfoResult

type OffsiteInfoResult struct {
	Active bool                     `json:"active"`
	Config *offsite.OffsiteSettings `json:"config,omitempty"`
}

func OffsiteInfo

func OffsiteInfo(deps *Dependencies) (*OffsiteInfoResult, error)

type OffsiteLogsParams

type OffsiteLogsParams struct {
	Limit int
}

type OffsiteTestResult

type OffsiteTestResult struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Error   string `json:"error,omitempty"`
}

func OffsiteTest

func OffsiteTest(deps *Dependencies) (*OffsiteTestResult, error)

type OpType

type OpType int

OpType represents the type of operation

const (
	OpTypeRead OpType = iota
	OpTypeWrite
)

type Operation

type Operation interface {
	// Name returns a human-readable name for the operation
	Name() string

	Execute(ctx context.Context) error

	// Type returns whether this is a read or write operation
	Type() OpType
}

Operation represents a unit of work that can be executed

type ParameterGroupDeleteParams

type ParameterGroupDeleteParams struct {
	Name string
}

ParameterGroupDeleteParams contains parameters for deleting a parameter group

type ParameterGroupDeleteResult

type ParameterGroupDeleteResult struct {
	Message string `json:"message"`
}

type ParameterGroupGetParams

type ParameterGroupGetParams struct {
	Name string
}

ParameterGroupGetParams contains parameters for getting a parameter group

type ParameterGroupGetResult

type ParameterGroupGetResult struct {
	GroupName  string                         `json:"groupName"`
	Parameters []parameters.ResolvedParameter `json:"parameters"`
}

type ParameterGroupInfo

type ParameterGroupInfo struct {
	Name       string                         `json:"name"`
	Parameters []parameters.ResolvedParameter `json:"parameters"`
}

type ParameterGroupListParams

type ParameterGroupListParams struct{}

type ParameterGroupListResult

type ParameterGroupListResult struct {
	Groups []ParameterGroupInfo `json:"groups"`
}

type ParameterGroupPutParams

type ParameterGroupPutParams struct {
	Name       string
	Parameters []byte // JSON data
}

ParameterGroupPutParams contains parameters for creating a parameter group

type ParameterGroupPutResult

type ParameterGroupPutResult struct {
	Message string `json:"message"`
}

type PostgreSQLStatus

type PostgreSQLStatus int

PostgreSQL connectivity status constants

const (
	PostgreSQLStatusOK PostgreSQLStatus = iota
	PostgreSQLStatusBrokenPort
	PostgreSQLStatusBrokenAuth
	PostgreSQLStatusOther
)

func TestPostgreSQLConnectivity

func TestPostgreSQLConnectivity(ctx context.Context, deps *Dependencies, instanceName string) PostgreSQLStatus

TestPostgreSQLConnectivity tests PostgreSQL connectivity and returns detailed status

type PullImageOp

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

PullImageOp pulls a PostgreSQL image from Docker Hub

func NewPullImageOp

func NewPullImageOp(deps *Dependencies, params PullImageParams) *PullImageOp

NewPullImageOp creates a new pull image operation

func (*PullImageOp) Execute

func (op *PullImageOp) Execute(ctx context.Context) error

func (*PullImageOp) GetResult

func (op *PullImageOp) GetResult() *PullImageResult

GetResult returns the operation result

func (*PullImageOp) Name

func (op *PullImageOp) Name() string

func (*PullImageOp) Type

func (op *PullImageOp) Type() OpType

type PullImageParams

type PullImageParams struct {
	Version string
	Image   string
}

PullImageParams contains parameters for pulling a Docker image

type PullImageResult

type PullImageResult struct {
	Version string
	Tags    []string
	Message string
}

PullImageResult contains the result of pulling a Docker image

type ReconfigureRDBMSOp

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

ReconfigureRDBMSOp reconfigures an existing RDBMS instance with a new parameter group

func NewReconfigureRDBMSOp

func NewReconfigureRDBMSOp(deps *Dependencies, params ReconfigureRDBMSParams) *ReconfigureRDBMSOp

NewReconfigureRDBMSOp creates a new reconfigure RDBMS operation

func (*ReconfigureRDBMSOp) Execute

func (op *ReconfigureRDBMSOp) Execute(ctx context.Context) error

func (*ReconfigureRDBMSOp) GetResult

func (op *ReconfigureRDBMSOp) GetResult() *ReconfigureRDBMSResult

GetResult returns the operation result

func (*ReconfigureRDBMSOp) Name

func (op *ReconfigureRDBMSOp) Name() string

func (*ReconfigureRDBMSOp) Type

func (op *ReconfigureRDBMSOp) Type() OpType

type ReconfigureRDBMSParams

type ReconfigureRDBMSParams struct {
	Name           string
	ParameterGroup string
}

ReconfigureRDBMSParams contains the parameters for reconfiguring an RDBMS instance

type ReconfigureRDBMSResult

type ReconfigureRDBMSResult struct {
	Instance *instances.RDBMSInstance
}

ReconfigureRDBMSResult contains the result of reconfiguring an RDBMS instance

type RemoveLocalBackupParams

type RemoveLocalBackupParams struct {
	InstanceName string
	BackupID     int
}

type RemoveLocalBackupResult

type RemoveLocalBackupResult struct {
	Message string `json:"message"`
}

type RemoveRemoteBackupParams

type RemoveRemoteBackupParams struct {
	InstanceName string
	BackupID     int
}

type RemoveRemoteBackupResult

type RemoveRemoteBackupResult struct {
	Message string `json:"message"`
}

type ResetDatabaseUserPasswordParams

type ResetDatabaseUserPasswordParams struct {
	InstanceName string
	Username     string
}

type ResetDatabaseUserPasswordResult

type ResetDatabaseUserPasswordResult struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Message  string `json:"message"`
}

type RestoreRDBMSParams

type RestoreRDBMSParams struct {
	// Either BackupID or FilePath must be provided (mutually exclusive)
	BackupID int    // ID from backup_history table
	FilePath string // Direct path to .tar.zst file

	InstanceName string // Target instance to restore to
	DatabaseName string // Database name inside the backup to restore
	RestoreAs    string // Optional: restore under a different name
	BackupDir    string // Backup directory for resolving relative paths
}

RestoreRDBMSParams contains parameters for restoring a database from backup

type RestoreRDBMSResult

type RestoreRDBMSResult struct {
	TargetDatabase string `json:"targetDatabase"`
	SourceBackup   string `json:"sourceBackup"`
	Message        string `json:"message"`
}

RestoreRDBMSResult contains the result of restoring a database

func RestoreRDBMS

func RestoreRDBMS(ctx context.Context, deps *Dependencies, params *RestoreRDBMSParams) (*RestoreRDBMSResult, error)

RestoreRDBMS restores a single database from a backup archive

type SetPasswordOp

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

SetPasswordOp is an operation to set a new password for an instance

func NewSetPasswordOp

func NewSetPasswordOp(deps *Dependencies, name, password string) *SetPasswordOp

NewSetPasswordOp creates a new operation to set password

func (*SetPasswordOp) Execute

func (op *SetPasswordOp) Execute(ctx context.Context) error

func (*SetPasswordOp) GetResult

func (op *SetPasswordOp) GetResult() *SetPasswordResult

func (*SetPasswordOp) Name

func (op *SetPasswordOp) Name() string

func (*SetPasswordOp) Type

func (op *SetPasswordOp) Type() OpType

type SetPasswordResult

type SetPasswordResult struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

type SwitchRDBMSOp

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

SwitchRDBMSOp switches an existing RDBMS instance to a different Docker image

func NewSwitchRDBMSOp

func NewSwitchRDBMSOp(deps *Dependencies, params SwitchRDBMSParams) *SwitchRDBMSOp

NewSwitchRDBMSOp creates a new switch RDBMS operation

func (*SwitchRDBMSOp) Execute

func (op *SwitchRDBMSOp) Execute(ctx context.Context) error

func (*SwitchRDBMSOp) GetResult

func (op *SwitchRDBMSOp) GetResult() *SwitchRDBMSResult

GetResult returns the operation result

func (*SwitchRDBMSOp) Name

func (op *SwitchRDBMSOp) Name() string

func (*SwitchRDBMSOp) Type

func (op *SwitchRDBMSOp) Type() OpType

type SwitchRDBMSParams

type SwitchRDBMSParams struct {
	Name    string
	Image   string
	Version string // empty = keep current instance version
}

SwitchRDBMSParams contains parameters for switching an instance's image

type SwitchRDBMSResult

type SwitchRDBMSResult struct {
	Instance *instances.RDBMSInstance
}

SwitchRDBMSResult contains the result of switching an instance's image

type UpdateStateOp

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

UpdateStateOp updates the state of an RDBMS instance

func NewUpdateStateOp

func NewUpdateStateOp(deps *Dependencies, params UpdateStateParams) *UpdateStateOp

func (*UpdateStateOp) Execute

func (op *UpdateStateOp) Execute(ctx context.Context) error

func (*UpdateStateOp) Name

func (op *UpdateStateOp) Name() string

func (*UpdateStateOp) Type

func (op *UpdateStateOp) Type() OpType

type UpdateStateParams

type UpdateStateParams struct {
	Name  string
	State string // "start" or "stop"
}

UpdateStateParams contains parameters for updating instance state

type UpgradeRDBMSOp

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

UpgradeRDBMSOp performs a major-version PostgreSQL upgrade of an instance using a logical dump/restore: it takes a verified full backup, destroys the old cluster volume, creates a fresh cluster at the target version (which automatically picks the correct data-dir mount for the major), then replays globals and every database into it.

A newer PostgreSQL server cannot start against an older major's data directory, so an in-place restart is impossible; dump/restore is the only universal path that also works with custom images (pgvector, postgis) where pg_upgrade would need both majors' binaries in one image.

func NewUpgradeRDBMSOp

func NewUpgradeRDBMSOp(deps *Dependencies, params UpgradeRDBMSParams) *UpgradeRDBMSOp

NewUpgradeRDBMSOp creates a new major-upgrade operation

func (*UpgradeRDBMSOp) Execute

func (op *UpgradeRDBMSOp) Execute(ctx context.Context) error

func (*UpgradeRDBMSOp) GetResult

func (op *UpgradeRDBMSOp) GetResult() *UpgradeRDBMSResult

GetResult returns the operation result

func (*UpgradeRDBMSOp) Name

func (op *UpgradeRDBMSOp) Name() string

func (*UpgradeRDBMSOp) Type

func (op *UpgradeRDBMSOp) Type() OpType

type UpgradeRDBMSParams

type UpgradeRDBMSParams struct {
	Name          string
	TargetVersion string // target PostgreSQL major version, e.g. "18"
	Image         string // optional target image; required for custom (non-postgres:) images
}

UpgradeRDBMSParams contains parameters for a major-version upgrade of an instance

type UpgradeRDBMSResult

type UpgradeRDBMSResult struct {
	Instance          *instances.RDBMSInstance `json:"instance"`
	FromVersion       string                   `json:"fromVersion"`
	ToVersion         string                   `json:"toVersion"`
	BackupID          int                      `json:"backupId"`
	DatabasesRestored int                      `json:"databasesRestored"`
}

UpgradeRDBMSResult contains the result of a major-version upgrade

type UploadBackupParams

type UploadBackupParams struct {
	InstanceName string
	BackupID     int
}

UploadBackupParams contains parameters for uploading a backup to S3

type UploadBackupResult

type UploadBackupResult struct {
	Message  string
	Location string
	Size     int64
}

UploadBackupResult contains the result of uploading a backup

func UploadBackup

func UploadBackup(ctx context.Context, deps *Dependencies, params UploadBackupParams) (*UploadBackupResult, error)

UploadBackup uploads a backup to S3

Jump to

Keyboard shortcuts

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