configsync

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIntegrity = errors.New("configsync: snapshot integrity mismatch")
View Source
var ErrLKGCorrupt = errors.New("configsync: last-known-good snapshot is corrupt")
View Source
var ErrNotReady = errors.New("configsync: snapshot not ready")
View Source
var ErrReadOnly = errors.New("configsync: store is read-only")
View Source
var ErrTransportUnavailable = errors.New("configsync: transport unavailable")

ErrTransportUnavailable marks a config-sync transport disconnect that is expected and self-healing: a control-plane restart or rollout (graceful GOAWAY, surfaced by gRPC as codes.Unavailable), a transient network blip, or a clean stream EOF. Adapters wrap such errors with this sentinel so the watch loop demotes them to WARN and simply reconnects, instead of raising ERROR alarms on routine control-plane rollouts.

Functions

func ReadinessCheck

func ReadinessCheck[T any](store ConfigStore[T]) func(context.Context) error

Types

type AESGCMCrypto

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

func NewAESGCMCrypto

func NewAESGCMCrypto(key []byte) (*AESGCMCrypto, error)

func (*AESGCMCrypto) Decrypt

func (c *AESGCMCrypto) Decrypt(ciphertext []byte) ([]byte, error)

func (*AESGCMCrypto) Encrypt

func (c *AESGCMCrypto) Encrypt(plaintext []byte) ([]byte, error)

type ConfigFetcher

type ConfigFetcher interface {
	Fetch(ctx context.Context, etag string) (raw []byte, version string, notModified bool, err error)
}

type ConfigStore

type ConfigStore[T any] interface {
	Load() (*Versioned[T], bool)
	Swap(v *Versioned[T])
	Version() string
}

type Crypto

type Crypto interface {
	Encrypt(plaintext []byte) ([]byte, error)
	Decrypt(ciphertext []byte) ([]byte, error)
}

type LKGStore

type LKGStore[T any] struct {
	// contains filtered or unexported fields
}

func NewLKGStore

func NewLKGStore[T any](crypto Crypto, codec SnapshotCodec[T], path string) *LKGStore[T]

func (*LKGStore[T]) Age

func (s *LKGStore[T]) Age() (time.Duration, bool)

func (*LKGStore[T]) Load

func (s *LKGStore[T]) Load() (*Versioned[T], error)

func (*LKGStore[T]) Persist

func (s *LKGStore[T]) Persist(v *Versioned[T]) error

type MemoryStore

type MemoryStore[T any] struct {
	// contains filtered or unexported fields
}

func NewMemoryStore

func NewMemoryStore[T any]() *MemoryStore[T]

func (*MemoryStore[T]) Load

func (s *MemoryStore[T]) Load() (*Versioned[T], bool)

func (*MemoryStore[T]) Swap

func (s *MemoryStore[T]) Swap(v *Versioned[T])

func (*MemoryStore[T]) Version

func (s *MemoryStore[T]) Version() string

type SnapshotCodec

type SnapshotCodec[T any] interface {
	Encode(snapshot T) (raw []byte, err error)
	Decode(raw []byte) (T, error)
	Version(raw []byte) string
}

type StreamTransport

type StreamTransport interface {
	Watch(ctx context.Context) (version string, err error)
	Ack(ctx context.Context, appliedVersion string) error
}

StreamTransport is the DP-side control channel: block for the next change notice, and report the version the data plane has applied. Implementations (the gRPC client) reconnect internally with backoff.

type Versioned

type Versioned[T any] struct {
	Version  string
	Snapshot T
	Raw      []byte
}

type Worker

type Worker[T any] struct {
	// contains filtered or unexported fields
}

func NewWorker

func NewWorker[T any](
	fetcher ConfigFetcher,
	store ConfigStore[T],
	transport StreamTransport,
	lkg *LKGStore[T],
	codec SnapshotCodec[T],
	logger *slog.Logger,
	cfg WorkerConfig,
	opts ...WorkerOption[T],
) *Worker[T]

NewWorker builds a convergence worker that drives the config-sync stream transport for change notices/acks and the fetcher for chunked snapshot pulls.

func (*Worker[T]) Converge

func (w *Worker[T]) Converge(ctx context.Context) error

func (*Worker[T]) Run

func (w *Worker[T]) Run(ctx context.Context) error

type WorkerConfig

type WorkerConfig struct {
	PollInterval time.Duration
	MinBackoff   time.Duration
	MaxBackoff   time.Duration
}

type WorkerOption

type WorkerOption[T any] func(*Worker[T])

WorkerOption customizes a Worker at construction time.

func WithOnApplied

func WithOnApplied[T any](fn func(context.Context)) WorkerOption[T]

WithOnApplied registers a hook run after a new snapshot version is swapped into the store. The data plane uses it to invalidate caches derived from the snapshot so edits to already-served gateways take effect without a restart.

Jump to

Keyboard shortcuts

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