routeoverride

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package routeoverride holds A-leg-scoped routing-override state and the focused persistence ports used by core runtime and the protected admin adapter. It does not expand b2bua.Store or pkg/lipsdk/continuity.Store.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound reports that the target A-leg does not exist.
	ErrNotFound = errors.New("routeoverride: a-leg not found")
	// ErrInvalidSelector reports a selector that fails normalization or bounds.
	ErrInvalidSelector = errors.New("routeoverride: invalid selector")
	// ErrRevisionExhausted reports that the next revision would overflow int64.
	ErrRevisionExhausted = errors.New("routeoverride: revision exhausted")
	// ErrUnavailable reports that the override store cannot complete the operation.
	ErrUnavailable = errors.New("routeoverride: store unavailable")
	// ErrNotImplemented reports that a standard continuity adapter has not yet
	// gained the optional override capability.
	ErrNotImplemented = errors.New("routeoverride: store capability is not implemented")
)

Functions

func NormalizeSelector

func NormalizeSelector(raw string) string

NormalizeSelector trims surrounding whitespace. Empty after trim is inactive input.

Types

type CommandService

type CommandService interface {
	Get(ctx context.Context, aLegID string) (State, error)
	Replace(ctx context.Context, aLegID, selector string) (State, error)
	Clear(ctx context.Context, aLegID string) (State, error)
}

CommandService is the generation-bound application port for admin commands. Persistence stays process-owned; validation is generation-owned.

type Reader

type Reader interface {
	Snapshot(ctx context.Context, aLegID string) (State, error)
}

Reader is the narrow per-turn snapshot port used by request preparation.

func AsReader

func AsReader(v any) (Reader, bool)

AsReader reports whether v implements the optional override reader capability.

type SelectorValidator

type SelectorValidator interface {
	ValidateSelector(ctx context.Context, raw string) error
}

SelectorValidator is a side-effect-free current-generation route preflight.

type Service

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

Service is the generation-bound command service. Persistence is process-owned; SelectorValidator is bound to the generation that constructed this instance.

func NewService

func NewService(store Store, validator SelectorValidator, now func() time.Time) (*Service, error)

NewService constructs a command service. Store and validator are required.

func (*Service) Clear

func (s *Service) Clear(ctx context.Context, aLegID string) (State, error)

func (*Service) Get

func (s *Service) Get(ctx context.Context, aLegID string) (State, error)

func (*Service) Replace

func (s *Service) Replace(ctx context.Context, aLegID, selector string) (State, error)

type State

type State struct {
	ALegID    string
	Active    bool
	Selector  string // empty when inactive
	Revision  int64  // 0 = never mutated
	UpdatedAt time.Time
}

State is the revisioned active/inactive routing override for one A-leg.

func Inactive

func Inactive(aLegID string) State

Inactive returns the never-mutated revision-0 state for an existing A-leg.

func (State) Clone

func (s State) Clone() State

Clone returns a value copy. Selector is a string, so callers cannot alias a mutable buffer held by the store.

func (State) Validate

func (s State) Validate() error

Validate enforces D2 invariants for a complete state value.

type Store

type Store interface {
	Reader
	Get(ctx context.Context, aLegID string) (State, error)
	Replace(ctx context.Context, aLegID, selector string, now time.Time) (State, error)
	Clear(ctx context.Context, aLegID string, now time.Time) (State, error)
}

Store is the optional continuity capability for revisioned override state. Standard memory and Bun adapters implement this in addition to b2bua.Store without changing the base public continuity contract.

func AsStore

func AsStore(v any) (Store, bool)

AsStore reports whether v implements the optional override store capability.

Directories

Path Synopsis
Package storecontract holds reusable contract tests for routeoverride.Store implementations (memory, SQLite, PostgreSQL).
Package storecontract holds reusable contract tests for routeoverride.Store implementations (memory, SQLite, PostgreSQL).

Jump to

Keyboard shortcuts

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