namespaces

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Default applies when callers omit a namespace.
	Default = "default"

	// MaxLength caps the length of namespaces, queue names, and key segments.
	MaxLength = 128
)

Variables

This section is empty.

Functions

func Normalize

func Normalize(ns, fallback string) (string, error)

Normalize lowercases and validates ns, applying fallback when ns is empty.

func NormalizeComponent

func NormalizeComponent(name string) (string, error)

NormalizeComponent lowercases and validates a single name component.

func NormalizeKey

func NormalizeKey(key string) (string, error)

NormalizeKey lowercases and validates a lock key. Keys may contain '/' to denote hierarchical segments; each segment must satisfy NormalizeComponent.

func Validate

func Validate(ns string) error

Validate reports whether ns satisfies namespace constraints.

Types

type Config

type Config struct {
	Query QueryEngines `json:"query"`
}

Config captures namespace-level configuration.

func ConfigFromProto

func ConfigFromProto(msg *lockdproto.NamespaceConfig) Config

ConfigFromProto converts the protobuf namespace config into the Go struct.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default namespace configuration.

func (*Config) Normalize

func (c *Config) Normalize()

Normalize applies default values for unset fields.

func (Config) SelectEngine

func (c Config) SelectEngine(hint search.EngineHint, caps search.Capabilities) (search.EngineHint, error)

SelectEngine determines the engine to use for the namespace based on the provided hint and actual adapter capabilities.

func (Config) ToProto

func (c Config) ToProto() *lockdproto.NamespaceConfig

ToProto converts the config into the protobuf representation.

func (Config) Validate

func (c Config) Validate() error

Validate ensures the configuration satisfies namespace constraints.

type ConfigLoadResult

type ConfigLoadResult struct {
	Config Config
	ETag   string
}

ConfigLoadResult captures a namespace config and its ETag.

type ConfigProvider

type ConfigProvider interface {
	DefaultNamespaceConfig() Config
}

ConfigProvider exposes the default namespace configuration for backends.

type ConfigStore

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

ConfigStore persists namespace configuration documents inside the storage backend.

func NewConfigStore

func NewConfigStore(backend storage.Backend, crypto *storage.Crypto, logger pslog.Logger, defaultCfg Config) *ConfigStore

NewConfigStore builds a ConfigStore backed by backend. When backend is nil a nil store is returned.

func (*ConfigStore) Default

func (s *ConfigStore) Default() Config

Default returns the store's default namespace configuration.

func (*ConfigStore) Load

func (s *ConfigStore) Load(ctx context.Context, namespace string) (ConfigLoadResult, error)

Load retrieves the namespace config and its ETag. When no config exists the default configuration is returned with an empty ETag.

func (*ConfigStore) Save

func (s *ConfigStore) Save(ctx context.Context, namespace string, cfg Config, expectedETag string) (string, error)

Save persists the namespace configuration enforcing the provided ETag when non-empty.

type FallbackMode

type FallbackMode string

FallbackMode determines how queries behave when the preferred engine is unavailable.

const (
	// FallbackScan allows queries to fall back to the scan engine.
	FallbackScan FallbackMode = "scan"
	// FallbackNone disables fallback; queries fail if the preferred engine is unavailable.
	FallbackNone FallbackMode = "none"
)

type QueryEngines

type QueryEngines struct {
	Preferred search.EngineHint `json:"preferred_engine"`
	Fallback  FallbackMode      `json:"fallback_engine"`
}

QueryEngines describes the preferred and fallback engines for /v1/query.

Jump to

Keyboard shortcuts

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