cache

package
v0.10.0 Latest Latest
Warning

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

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

Documentation

Overview

Package cache provides shared helpers for cache resource adapters.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilController = errors.New("cache: nil generation controller")
	ErrVerifyFailed  = errors.New("cache: generation verify failed")
	ErrAborted       = errors.New("cache: generation aborted")
)

Functions

This section is empty.

Types

type BuildFunc

type BuildFunc func(ctx context.Context, gen uint64) (map[string]string, error)

BuildFunc populates a reserved generation's seed data.

type EpochAdvancer

type EpochAdvancer interface {
	Advance(id resource.ResourceID, reason string) (resource.EpochAdvance, error)
}

EpochAdvancer optionally advances a registry epoch after activation.

type FlowOptions

type FlowOptions struct {
	ResourceID resource.ResourceID
	Build      BuildFunc
	Verify     VerifyFunc
	Retire     RetireFunc
	Epochs     EpochAdvancer
	DryRun     bool
}

FlowOptions configures a generation rebuild flow.

type FlowResult

type FlowResult struct {
	Previous  uint64                `json:"previous"`
	Reserved  uint64                `json:"reserved"`
	Activated uint64                `json:"activated,omitempty"`
	DryRun    bool                  `json:"dry_run,omitempty"`
	Epoch     resource.EpochAdvance `json:"epoch,omitempty"`
	Retired   bool                  `json:"retired,omitempty"`
}

FlowResult is a sanitized outcome (no cache values).

func RunGenerationFlow

func RunGenerationFlow(ctx context.Context, ctrl GenerationController, opts FlowOptions) (FlowResult, error)

RunGenerationFlow executes reserve → build → verify → activate → epoch → retire. On any failure after reserve, AbortGeneration is called.

type GenerationController

type GenerationController interface {
	BuildGeneration(ctx context.Context) (uint64, error)
	ActivateGeneration(gen uint64, seed map[string]string) error
	AbortGeneration()
	Generation() uint64
}

GenerationController is implemented by memory (and similar) cache adapters.

type RetireFunc

type RetireFunc func(ctx context.Context, previous uint64) error

RetireFunc cleans up prior generation artifacts after activation.

type VerifyFunc

type VerifyFunc func(ctx context.Context, gen uint64, seed map[string]string) error

VerifyFunc checks a built seed before activation.

Directories

Path Synopsis
Package memory provides an in-process cache resource for tests and demos.
Package memory provides an in-process cache resource for tests and demos.
Package redis is a thin cache resource adapter.
Package redis is a thin cache resource adapter.

Jump to

Keyboard shortcuts

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