dbparams

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package dbparams is the typed allowlist of engine tuning parameters a managed database accepts. Deny by default: a name absent from the allowlist is refused, and every accepted value is re-rendered from its parsed number or enum, so no caller string ever reaches a command line.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedEngine = errors.New("this engine takes no tuning parameters")

ErrUnsupportedEngine is returned for an engine with no allowlist.

Functions

func Args

func Args(engine string, params map[string]string, lim Limits) []string

Args renders applied parameters as separate argv elements. Entries that fail validation are dropped, so a stored row edited by hand never reaches the engine.

func ClampMemory

func ClampMemory(engine, name, value string, lim Limits) (string, bool)

ClampMemory lowers a valid memory parameter above lim's ceiling to the ceiling, in the value's own unit, so a lower cap still bounds the engine instead of the parameter falling back to an uncapped default.

func Denied

func Denied(engine string) []string

Denied returns the explicitly refused names for engine.

func Fingerprint

func Fingerprint(args []string) string

Fingerprint is a short hash of the rendered args, "" when there are none, so a database without parameters keeps its existing container label set.

func Incompatible

func Incompatible(engine, version string, params map[string]string, lim Limits) []string

Incompatible returns the sorted names in params that the given engine version refuses, through the same validators staging uses plus the version gates.

func MemoryCeiling

func MemoryCeiling(limitBytes int64, adminMB int) int64

MemoryCeiling is 75 percent of a memory limit, or the admin ceiling when the database has none.

func Validate

func Validate(engine string, params map[string]string, lim Limits) (map[string]string, error)

Validate checks every name and value and returns the canonical form.

func ValidateOne

func ValidateOne(engine, name, value string, lim Limits) (string, error)

ValidateOne checks one parameter and returns its canonical value.

Types

type Family

type Family string

Family groups engines that share a flag syntax and a parameter list.

const (
	FamilyPostgres Family = "postgres"
	FamilyMySQL    Family = "mysql"
	FamilyRedis    Family = "redis"
	FamilyMongo    Family = "mongodb"
)

Engine families with an allowlist.

func FamilyFor

func FamilyFor(engine string) (Family, bool)

FamilyFor maps an engine to its parameter family; ok is false when the engine takes no tuning parameters.

type Kind

type Kind string

Kind is how a parameter value is parsed and re-rendered.

const (
	KindInt   Kind = "int"
	KindFloat Kind = "float"
	KindSize  Kind = "size"
	KindEnum  Kind = "enum"
	KindBool  Kind = "bool"
)

Parameter kinds.

type Limits

type Limits struct {
	MaxConnections int
	MaxMemoryBytes int64
}

Limits are admin bounds read from live runtime settings per request.

type Spec

type Spec struct {
	Name          string   `json:"name"`
	Kind          Kind     `json:"kind"`
	Default       string   `json:"default"`
	Min           float64  `json:"min,omitempty"`
	Max           float64  `json:"max,omitempty"`
	Options       []string `json:"options,omitempty"`
	ConnectionCap bool     `json:"connection_cap,omitempty"`
	MemoryCap     bool     `json:"memory_cap,omitempty"`
	Description   string   `json:"description"`
}

Spec describes one allowlisted parameter. Min and Max are bytes for KindSize. ConnectionCap marks the parameter the admin ceiling bounds.

func Specs

func Specs(engine string) []Spec

Specs returns the allowlist for engine, nil when unsupported.

Jump to

Keyboard shortcuts

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