Help us shape the future of Go! Take the 2026 Go Developer Survey

parameters

package
v0.1.94 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultParameterGroup = "default:2025-08-27"
View Source
const (
	ParameterTypePostgresCLIArg = "postgres_cli_arg"
)

Variables

View Source
var ErrSharedMemoryTooLarge = errors.New("estimated PostgreSQL shared memory exceeds container RAM")

ErrSharedMemoryTooLarge is returned when the resolved parameter group would make PostgreSQL request a shared-memory arena larger than the container's RAM. Tagged so callers can map it to HTTP 400 before destroying anything.

Functions

func EstimateSharedMemoryBytes added in v0.1.78

func EstimateSharedMemoryBytes(resolved []ResolvedParameter) (est int64, breakdown string, exact bool)

EstimateSharedMemoryBytes returns a conservative estimate of the PostgreSQL shared-memory segment implied by resolved GUCs (shared_buffers + WAL buffers + lock table + a fixed overhead for other arenas). Unset GUCs use documented PostgreSQL defaults.

exact reports whether every GUC it read parsed cleanly. When it is false the estimate is a guess and callers must not refuse on it. Parameters whose type is not postgres_cli_arg are skipped, matching the Docker layer, which only turns that type into `postgres -c name=value`.

func ValidateForContainer added in v0.1.78

func ValidateForContainer(resolved []ResolvedParameter, ramMB int) error

ValidateForContainer estimates the shared-memory arena implied by a resolved group and refuses it when it cannot fit in ramMB. Call this at create/apply time with the instance's real RAM, not at PUT time (a group that is fatal on 8 GiB can be fine on 32 GiB).

It refuses ONLY the case it can prove: an arena that does not fit. Anything it cannot parse leaves the estimate inexact and the group is allowed through, because the container-start path already catches a group PostgreSQL rejects and rolls back to the previous one. The asymmetry is deliberate — a false refusal here blocks `oddk snapshot apply`, which has no fallback.

func ValidateParameterIdentity added in v0.1.78

func ValidateParameterIdentity(param Parameter, index int) error

ValidateParameterIdentity checks the fields that PUT can enforce without knowing the target instance's RAM: name shape and that type is the only one CreateContainer/RecreateContainer actually pass through as postgres -c.

This runs at PUT time only. It is deliberately NOT re-run when a container is built: groups stored before this validation existed must keep working, and a group that only ever produced a silently-ignored parameter must not become the reason a `snapshot apply` cannot rebuild the deployment.

func ValidateParameterValue

func ValidateParameterValue(value, valueType string) error

ValidateParameterValue validates a parameter value against its type

Types

type ExpressionContext

type ExpressionContext struct {
	DBContainerMemoryMB  int
	DBContainerCoreCount int
	MaxConnections       int
}

type Parameter

type Parameter struct {
	GroupName string `db:"group_name" json:"groupName"`
	Name      string `db:"name" json:"name"`
	Type      string `db:"type" json:"type"`
	ValueType string `db:"value_type" json:"valueType"`
	Value     string `db:"value" json:"value"`
	CreatedAt string `db:"created_at" json:"createdAt"`
}

func GetDefaultParameters

func GetDefaultParameters() []Parameter

GetDefaultParameters returns the default parameter configuration for PostgreSQL instances. This function acts as a constant by always returning the same configuration.

func ParseListJSON added in v0.1.84

func ParseListJSON(raw json.RawMessage) ([]Parameter, error)

ParseListJSON accepts a bare array or the object emitted by parameters get --json.

type ParameterGroup

type ParameterGroup struct {
	Name       string      `json:"name"`
	Parameters []Parameter `json:"parameters"`
}

type ParameterStore

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

func NewParameterStore

func NewParameterStore(db *sqlx.DB) *ParameterStore

func (*ParameterStore) CreateGroup

func (s *ParameterStore) CreateGroup(groupName string, parameters []Parameter) error

func (*ParameterStore) DeleteGroup

func (s *ParameterStore) DeleteGroup(groupName string) error

func (*ParameterStore) EnsureDefaultParameterGroup

func (s *ParameterStore) EnsureDefaultParameterGroup() error

func (*ParameterStore) GetGroup

func (s *ParameterStore) GetGroup(groupName string) (*ParameterGroup, error)

func (*ParameterStore) GroupExists

func (s *ParameterStore) GroupExists(groupName string) (bool, error)

func (*ParameterStore) ListGroups

func (s *ParameterStore) ListGroups() ([]string, error)

func (*ParameterStore) ResolveParameterGroup

func (s *ParameterStore) ResolveParameterGroup(groupName string, coreCount, memoryMB int) ([]ResolvedParameter, error)

type ResolvedParameter

type ResolvedParameter struct {
	Name      string `json:"name"`
	Type      string `json:"type"`
	ValueType string `json:"valueType"`
	Value     string `json:"value"`
}

func ResolveParameters

func ResolveParameters(parameters []Parameter, coreCount, memoryMB int) ([]ResolvedParameter, error)

ResolveParameters resolves a list of parameters with the given system resources This function is decoupled from the store for easier testing

Jump to

Keyboard shortcuts

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