consulstate

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package consulstate supplies bounded encrypted CAS documents to Consul companions.

Index

Constants

View Source
const MaxPayload = 384 << 10

MaxPayload keeps each encrypted value below Consul's 512 KiB KV limit.

Variables

View Source
var (
	ErrInvalid     = errors.New("invalid Consul backend configuration or input")
	ErrUnavailable = errors.New("Consul backend unavailable or write outcome uncertain")
	ErrCapacity    = errors.New("Consul backend capacity reached")
)

Functions

func Normalize

func Normalize(name, prefix, timeout, defaultPrefix string) (string, string, error)

Normalize applies common defaults without accessing Caddy or Consul.

func Parse

func Parse(d *caddyfile.Dispenser) (string, [][]string, error)

Parse reads a module name and optional flat block. Callers validate each setting.

func Update

func Update[T any](ctx context.Context, h *Handle, initial func() T, apply func(*T) (bool, error)) error

Update retries only definite CAS conflicts, up to eight attempts. The callback must be retry-safe and keep results private until Update returns nil. Returning changed=true with an error commits terminal revocation before returning it. Network errors never retry, even when a server may already have committed.

func ValidText

func ValidText(s string, limit int) bool

ValidText checks literal identifiers without changing their bytes.

Types

type Binding

type Binding struct {

	// Identity is safe configuration metadata, including the effective encryption key.
	Identity string
	// contains filtered or unexported fields
}

Binding captures only borrowed global storage resources. It never closes them.

func Bind

func Bind(ctx caddy.Context) (*Binding, error)

Bind captures Caddy's ready supported storage client and a copied AES key.

func Capture

func Capture(storage *storageconsul.ConsulStorage) (*Binding, error)

Capture freezes an explicitly supplied Caddy storage client and encryption key. Bind is the production entry point; tests use independent disposable clients.

func (*Binding) Open

func (b *Binding) Open(category, name, prefix, timeout string) (*Handle, error)

Open constructs a distinct handle without writing or adopting any state.

type Handle

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

Handle is one app-owned logical handle to a category/name document.

func (*Handle) Check

func (h *Handle) Check(ctx context.Context, index uint64) (bool, error)

Check fences a read/callback against concurrent writes without changing the key.

func (*Handle) Close

func (h *Handle) Close() error

Close retires only this handle, leaving pending peer work and Caddy's client intact.

func (*Handle) Context

func (h *Handle) Context(ctx context.Context) (context.Context, context.CancelFunc)

func (*Handle) Load

func (h *Handle) Load(ctx context.Context, value any) (uint64, error)

Load decodes a detached document. Missing keys leave the supplied initial value intact.

func (*Handle) Ready

func (h *Handle) Ready() bool

Jump to

Keyboard shortcuts

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