ds

package
v0.11.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: PostgreSQL Imports: 8 Imported by: 0

Documentation

Overview

ds contains data structure implementations that can be reused across other modules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetToString added in v0.9.0

func SetToString[T ~string](s Set[T]) string

SetToString is a shortcut for producing a sorted, comma-separated string representation of a Set of string-ish values.

Types

type PgEdgeVersion added in v0.8.0

type PgEdgeVersion struct {
	PostgresVersion *Version `json:"postgres_version"`
	SpockVersion    *Version `json:"spock_version"`
	// Stability is the release stability of the manifest image backing this
	// version. Empty when the host does not report one (eg. the systemd
	// orchestrator); treat empty as stable.
	Stability Stability `json:"stability,omitempty"`
}

func MustParsePgEdgeVersion added in v0.9.0

func MustParsePgEdgeVersion(postgresVersion, spockVersion string) *PgEdgeVersion

func ParsePgEdgeVersion added in v0.9.0

func ParsePgEdgeVersion(postgresVersion, spockVersion string) (*PgEdgeVersion, error)

func (*PgEdgeVersion) Clone added in v0.8.0

func (v *PgEdgeVersion) Clone() *PgEdgeVersion

func (*PgEdgeVersion) Compare added in v0.8.0

func (v *PgEdgeVersion) Compare(other *PgEdgeVersion) int

func (*PgEdgeVersion) Equals added in v0.8.0

func (v *PgEdgeVersion) Equals(other *PgEdgeVersion) bool

func (*PgEdgeVersion) GreaterThan added in v0.8.0

func (v *PgEdgeVersion) GreaterThan(other *PgEdgeVersion) bool

func (*PgEdgeVersion) LessThan added in v0.8.0

func (v *PgEdgeVersion) LessThan(other *PgEdgeVersion) bool

func (*PgEdgeVersion) Normalize added in v0.9.0

func (v *PgEdgeVersion) Normalize() (*PgEdgeVersion, error)

Normalize returns the Postgres version in major.minor format and the Spock version in major format. This matches the way that versions are currently provided in our API.

func (*PgEdgeVersion) String added in v0.8.0

func (v *PgEdgeVersion) String() string

type Set

type Set[T comparable] map[T]bool

Set is a generic set type.

func NewSet

func NewSet[T comparable](elements ...T) Set[T]

func SetDifference

func SetDifference[T comparable](a, b []T) Set[T]

SetDifference (a-b) returns the set of elements that are in a, but not b.

func SetSymmetricDifference added in v0.7.0

func SetSymmetricDifference[T comparable](a, b []T) Set[T]

SetSymmetricDifference (a-b)∪(b-a) returns the set of elements that are in either a or b, but not both.

func (Set[T]) Add

func (s Set[T]) Add(elements ...T)

Add adds an element to the set.

func (Set[T]) Difference

func (s Set[T]) Difference(o Set[T]) Set[T]

Difference (s-o) returns elements that are in the receiver set, but not the given set 'o'.

func (Set[T]) Empty

func (s Set[T]) Empty() bool

Empty returns whether the set is empty.

func (Set[T]) Equal

func (s Set[T]) Equal(o Set[T]) bool

Equal returns whether the given set is equal to the receiver set.

func (Set[T]) Has

func (s Set[T]) Has(element T) bool

Has returns true if the given element is in the set.

func (Set[T]) Intersection

func (s Set[T]) Intersection(o Set[T]) Set[T]

Intersection (s∩o) returns elements that are in both sets.

func (Set[T]) Remove

func (s Set[T]) Remove(element T)

Remove removes an element to the set.

func (Set[T]) Size

func (s Set[T]) Size() int

Size returns the number of elements in the set.

func (Set[T]) SymmetricDifference

func (s Set[T]) SymmetricDifference(o Set[T]) Set[T]

SymmetricDifference (s-o)∪(o-s) returns elements that are in the receiver set, but not the given set 'o', along with those that are in 'o', but not the receiver set.

func (Set[T]) ToSlice

func (s Set[T]) ToSlice() []T

ToSlice returns a slice of all the elements in the set.

func (Set[T]) ToSortedSlice

func (s Set[T]) ToSortedSlice(cmp func(a T, b T) int) []T

ToSortedSlice returns a sorted slice of all the elements in the set.

func (Set[T]) Union

func (s Set[T]) Union(o Set[T]) Set[T]

Union (s∪o) returns all elements from both sets.

type Stability

type Stability string

Stability indicates the release stability of a manifest image entry.

From least to most mature:

  • StabilityDev: a mutable channel tag. Its contents can change under a running deployment and its declared postgres_version can drift from what the tag resolves to.
  • StabilityBeta: a feature-complete pre-release, immutable build. Defined for completeness.
  • StabilityRC: a release candidate, immutable build believed to be GA-quality.
  • StabilityStable: generally available.
  • StabilityDeprecated: still resolvable and still supported for existing databases, but should not be chosen for a new database.
const (
	StabilityDev        Stability = "dev"
	StabilityBeta       Stability = "beta"
	StabilityRC         Stability = "rc"
	StabilityStable     Stability = "stable"
	StabilityDeprecated Stability = "deprecated"
)

func (Stability) AllowedAsDefault

func (s Stability) AllowedAsDefault() bool

AllowedAsDefault reports whether an entry with this stability may be the manifest default (the image chosen when a create request omits the version). Only stable entries qualify.

func (Stability) AllowedAsUpgradeTarget

func (s Stability) AllowedAsUpgradeTarget() bool

AllowedAsUpgradeTarget reports whether an operator may apply an image upgrade to an entry with this stability when they name it explicitly. Stable and rc qualify (an rc is the exact bits intended for GA), as does deprecated (so a database can be moved along a sunset line). Dev and beta do not.

func (Stability) Normalized

func (s Stability) Normalized() Stability

func (Stability) OfferedForUpgrade

func (s Stability) OfferedForUpgrade() bool

OfferedForUpgrade reports whether an entry with this stability is surfaced in a database's available_upgrades list. Only stable entries are.

func (Stability) Valid

func (s Stability) Valid() bool

type Version added in v0.8.0

type Version struct {
	Components []uint64 `json:"components"`
	// PreRelease is the optional suffix after a "-" (e.g. "beta.1" in
	// "6.0.0-beta.1"). It is an opaque string, not decomposed into SemVer
	// precedence rules, and is intentionally dropped by MajorVersion and
	// MajorMinorVersion since a major/major-minor bucket never carries one.
	PreRelease string `json:"pre_release,omitempty"`
}

func MustParseVersion added in v0.8.0

func MustParseVersion(s string) *Version

func ParseImageTag

func ParseImageTag(image string) (pgVer, spockVer *Version, ok bool)

ParseImageTag extracts the Postgres and Spock versions from an image reference following the pgEdge tag format. Returns ok=false if the tag does not match the expected format (e.g. a dev build tag like "my-build"). Digest suffixes (e.g. @sha256:…) are stripped before parsing.

func ParseVersion added in v0.8.0

func ParseVersion(s string) (*Version, error)

func (*Version) Clone added in v0.8.0

func (v *Version) Clone() *Version

func (*Version) Compare added in v0.8.0

func (v *Version) Compare(other *Version) int

Compare orders by numeric components first. If those are equal, a pre-release never compares equal to its release counterpart (a release sorts after any pre-release of the same numeric version), and two different pre-releases of the same numeric version fall back to a plain string comparison. This is NOT full SemVer pre-release precedence — it's just enough to avoid falsely claiming two different versions are equal.

func (*Version) Major added in v0.8.0

func (v *Version) Major() (uint64, bool)

func (*Version) MajorMinorVersion added in v0.9.0

func (v *Version) MajorMinorVersion() *Version

MajorMinorVersion returns the major.minor components. PreRelease is intentionally dropped: a major.minor bucket never carries a pre-release suffix.

func (*Version) MajorString added in v0.8.0

func (v *Version) MajorString() (string, bool)

func (*Version) MajorVersion added in v0.8.0

func (v *Version) MajorVersion() *Version

MajorVersion returns just the major component. PreRelease is intentionally dropped: a major-version bucket never carries a pre-release suffix.

func (*Version) MarshalText added in v0.8.0

func (v *Version) MarshalText() (data []byte, err error)

func (*Version) String added in v0.8.0

func (v *Version) String() string

func (*Version) UnmarshalJSON added in v0.8.0

func (v *Version) UnmarshalJSON(data []byte) error

func (*Version) UnmarshalText added in v0.8.0

func (v *Version) UnmarshalText(data []byte) error

type VersionConstraint added in v0.8.0

type VersionConstraint struct {
	Min *Version `json:"min,omitempty"`
	Max *Version `json:"max,omitempty"`
}

VersionConstraint defines an optional minimum and/or maximum version bound. A nil Min or Max means no restriction on that end of the range.

func (*VersionConstraint) IsSatisfied added in v0.8.0

func (c *VersionConstraint) IsSatisfied(v *Version) bool

IsSatisfied returns true if v falls within the constraint's bounds.

func (*VersionConstraint) String added in v0.8.0

func (c *VersionConstraint) String() string

Jump to

Keyboard shortcuts

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