shadow

package
v0.0.0-...-2769864 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ReadFromPrimary   = "primary"
	ReadFromSecondary = "secondary"
)

Variables

This section is empty.

Functions

func ReadFromContext

func ReadFromContext(ctx context.Context) string

ReadFromContext returns the per-request readFrom override, or "".

func WithReadFrom

func WithReadFrom(ctx context.Context, readFrom string) context.Context

WithReadFrom returns a context that overrides the shadow backend's read source for the duration of the request.

Types

type Backend

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

Backend dual-writes every mutation to both halves and serves reads from the one named by readFrom.

The secondary is the DURABLE half (the operator wires primary=inmem, secondary=postgres), so its write errors are authoritative and reach the caller under BOTH read sources. readFrom selects where reads are served, not which half is durable: swallowing a secondary write error under readFrom=primary is still silent permanent loss, because the ephemeral primary is gone on the next pod roll.

func New

func New(primary, secondary memory.Backend, readFrom string, logger logr.Logger) (*Backend, error)

func (*Backend) Capabilities

func (b *Backend) Capabilities() memory.Capabilities

func (*Backend) Delete

func (b *Backend) Delete(ctx context.Context, scope memory.Scope, kind, id string) error

func (*Backend) DeleteScope

func (b *Backend) DeleteScope(ctx context.Context, scope memory.Scope) error

func (*Backend) Get

func (b *Backend) Get(ctx context.Context, scope memory.Scope, kind, id string) (memory.Entry, bool, error)

func (*Backend) Put

func (b *Backend) Put(ctx context.Context, e memory.Entry) error

func (*Backend) Query

func (b *Backend) Query(ctx context.Context, q memory.Query) (memory.QueryResult, error)

func (*Backend) QueryAllScopes

func (b *Backend) QueryAllScopes(ctx context.Context, q memory.CrossScopeQuery) (memory.QueryResult, error)

func (*Backend) Status

func (b *Backend) Status(ctx context.Context, scope memory.Scope) (memory.ScopeStatus, error)

Jump to

Keyboard shortcuts

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