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

keyspace

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package keyspace owns namespace syntax and typed key codecs shared by infrastructure features.

Index

Constants

View Source
const MaxKeyBytes = 4096

MaxKeyBytes bounds a logical key before hashing; features may impose a lower limit.

Variables

This section is empty.

Functions

func ValidName

func ValidName(name string) bool

ValidName reports whether a bounded namespace/family component is valid.

Types

type Codec

type Codec[K any] struct {
	// contains filtered or unexported fields
}

Codec encodes one concrete key type. Callbacks must be deterministic, concurrency-safe and return different text for distinct semantic keys. The consuming feature validates key size and syntax before backend access.

func NewCodec

func NewCodec[K any](encode func(K) (string, error)) Codec[K]

NewCodec creates a key codec from the supplied encoding function.

func SignedKeys

func SignedKeys[K ~int | ~int8 | ~int16 | ~int32 | ~int64]() Codec[K]

SignedKeys preserves exact signed integer keys, including named natural IDs.

func StringKeys

func StringKeys[K ~string]() Codec[K]

StringKeys creates a codec that uses the string key directly.

func TextKeys

func TextKeys[K encoding.TextMarshaler]() Codec[K]

TextKeys creates a codec that uses each key's MarshalText method.

func UnsignedKeys

func UnsignedKeys[K ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr]() Codec[K]

UnsignedKeys preserves the full uint64 range without a floating-point conversion.

func (Codec[K]) Encode

func (c Codec[K]) Encode(key K) (string, error)

Encode calls the declared codec. Feature APIs isolate callback failures and validate the resulting address; direct adapter callers own those boundaries.

func (Codec[K]) Validate

func (c Codec[K]) Validate() error

Validate checks that the codec has an encoding function.

type Feature

type Feature string

Feature identifies the physical key family owned by a framework adapter.

type Namespace

type Namespace struct{ Application, Environment string }

Namespace separates applications and environments sharing a backend. Components contain 1–128 ASCII letters, digits, dots, underscores or hyphens.

func (Namespace) Validate

func (n Namespace) Validate() error

Validate validates the application and environment names.

Jump to

Keyboard shortcuts

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