keyspace

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 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]

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]

func TextKeys

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

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

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

Jump to

Keyboard shortcuts

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