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

util

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: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OddkNetworkName is the name of the custom Docker bridge network.
	OddkNetworkName = "oddk-bridge"
	// GatewayIP is the bridge gateway address that PostgreSQL instances
	// publish their ports on. It is host-local: not reachable from outside
	// the host without a tunnel.
	GatewayIP = "10.88.0.1"
	// OddkSubnet is the bridge network's subnet; GatewayIP lives inside it.
	OddkSubnet = "10.88.0.0/16"
)

ODDK's Docker bridge network. These are the single source of truth for the network name and gateway address; every instance's PostgreSQL binds to the gateway, helper containers attach to the network, and the CLI prints connection strings pointing at the gateway.

Variables

View Source
var BackupCounter = NewCounter()

BackupCounter is a global counter for backup naming

Functions

func GenerateSecurePassword

func GenerateSecurePassword(length int) string

func GetSystemResourceLimits

func GetSystemResourceLimits() (int, int, error)

func ParseRAMString

func ParseRAMString(ramStr string) (int, error)

func PostgresURI added in v0.1.78

func PostgresURI(password string, port int, database string) string

PostgresURI builds a libpq/pgx URL with the password percent-encoded. Auto-generated secrets are base64url and happen to be URL-safe; passwords set via NEW_PGPASSWORD are not, and a raw %s interpolation breaks on @ : / and %.

func ValidateBasicResourceBounds

func ValidateBasicResourceBounds(cpuCores, ramMB int) error

func ValidateInstanceName

func ValidateInstanceName(name string) error

ValidateInstanceName checks that a new instance name is safe to embed in Docker names, URLs and file paths. Existing instances are not re-validated.

func ValidateSystemResources

func ValidateSystemResources(cpuCores, ramMB int) error

Types

type Counter

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

Counter provides monotonic counters for unique naming within the same timestamp

func NewCounter

func NewCounter() *Counter

NewCounter creates a new monotonic counter

func (*Counter) GetNext

func (c *Counter) GetNext(timestamp string) int

GetNext returns the next counter value for a given timestamp

func (*Counter) Len

func (c *Counter) Len() int

Len returns the number of counters (for testing)

Jump to

Keyboard shortcuts

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