apimachineryk8s.io/apimachinery/pkg/sharding Index | Files

package sharding

import "k8s.io/apimachinery/pkg/sharding"

Index

Functions

func HashField

func HashField(value string) string

HashField computes a hash of value and returns it as a 16-character lowercase hex string (no "0x" prefix).

func HexLess

func HexLess(a, b string) bool

HexLess compares two 0x-prefixed lowercase hex strings numerically. Both values must be normalized to 16 hex digits (e.g. "0x0000000000000000"), except for the special upper bound "0x10000000000000000" (2^64) which has 17.

func ResolveFieldValue

func ResolveFieldValue(obj runtime.Object, fieldPath string) (string, error)

ResolveFieldValue extracts a metadata field value from a runtime.Object based on the given field path.

Field paths use CEL-style object-rooted syntax ("object.metadata.<field>"), which differs from the fieldSelector format ("metadata.<field>"). The "object." prefix anchors the path to the resource being filtered.

Supported field paths:

Types

type Selector

type Selector interface {
	// Matches returns true if the given object matches the shard selector.
	Matches(obj runtime.Object) (bool, error)

	// Empty returns true if the selector matches everything (no filtering).
	Empty() bool

	// String returns the wire-format string representation that can be
	// round-tripped through Parse.
	String() string

	// Requirements returns the list of shard range requirements.
	Requirements() []ShardRangeRequirement

	// DeepCopySelector returns a deep copy of the selector.
	DeepCopySelector() Selector
}

Selector represents a shard selector that can match objects based on hash ranges of their metadata fields. It follows the labels.Selector pattern from the Kubernetes API.

func Everything

func Everything() Selector

Everything returns a selector that matches all objects.

func NewSelector

func NewSelector(reqs ...ShardRangeRequirement) Selector

NewSelector creates a Selector from the given requirements. All requirements must use the same Key; this is validated at match time. If no requirements are provided, returns Everything().

type ShardRangeRequirement

type ShardRangeRequirement struct {
	// Key is the field path, e.g. "object.metadata.uid"
	Key string
	// Start is the inclusive lower bound as a 0x-prefixed lowercase hex string.
	// Minimum value is "0x0000000000000000".
	Start string
	// End is the exclusive upper bound as a 0x-prefixed lowercase hex string.
	// Maximum value is "0x10000000000000000" (2^64).
	End string
}

ShardRangeRequirement represents a single shard range requirement. It specifies a field path to hash and a hex range [Start, End) for filtering. The hash space is FNV-1a 64-bit: [0x0000000000000000, 0x10000000000000000). Both Start and End must be specified (no empty/unbounded values).

Source Files

accessor.go hash.go selector.go types.go

Version
v0.36.0 (latest)
Published
Apr 22, 2026
Platform
js/wasm
Imports
5 packages
Last checked
10 minutes ago

Tools for package owners.