parameters

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package parameters provides shared caching and transformations for configuration providers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Age

func Age(d time.Duration) *time.Duration

Age returns a duration pointer for an explicit cache lifetime, including zero.

func ClearCaches

func ClearCaches()

ClearCaches clears all initialized default providers. Explicit providers have their own ClearCache methods. Default AWS configuration and AppConfig sessions are retained.

func GetError

func GetError(name string, err error) error

GetError normalizes retrieval errors without losing typed library errors.

func TransformValue

func TransformValue(name string, value any, transform Transform) (any, error)

TransformValue decodes JSON or base64 text. Auto selects by the name suffix. Binary returns UTF-8 text; raw byte values stay bytes when no transform is used.

Types

type Cache

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

Cache is safe for concurrent retrievals. Construct one per provider, not per invocation. SDK options are not cache keys: use ForceFetch or separate providers when they change. Concurrent misses may fetch independently, matching the reference provider.

func NewCache

func NewCache(clock func() time.Time) *Cache

NewCache accepts an optional clock for deterministic expiry tests.

func (*Cache) ClearCache

func (c *Cache) ClearCache()

ClearCache also prevents in-flight Get/GetMultiple callbacks from repopulating entries.

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, name string, options Options, fetch func(context.Context) (any, error)) (any, error)

Get fetches and transforms a value on a cache miss. A nil value means missing.

func (*Cache) GetMultiple

func (c *Cache) GetMultiple(ctx context.Context, path string, options Options, fetch func(context.Context) (map[string]any, error)) (map[string]any, error)

func (*Cache) Lookup

func (c *Cache) Lookup(name string, options Options) (any, bool)

Lookup and Store share single-value entries with batched provider operations.

func (*Cache) Store

func (c *Cache) Store(name string, value any, options Options)

Store caches an already transformed value returned by a batched operation.

type GetParameterError

type GetParameterError struct {
	Name string
	Err  error
}

GetParameterError preserves the underlying SDK or context error for errors.Is/As.

func (*GetParameterError) Error

func (e *GetParameterError) Error() string

func (*GetParameterError) Unwrap

func (e *GetParameterError) Unwrap() error

type Options

type Options struct {
	MaxAge                *time.Duration
	ForceFetch            bool
	Transform             Transform
	ThrowOnMissing        bool
	ThrowOnTransformError bool
}

Options controls one retrieval. A nil MaxAge reads the environment on each call. MaxAge controls new cache entries; ForceFetch bypasses existing entries.

func (Options) Lifetime

func (o Options) Lifetime() time.Duration

type ParameterNotFoundError

type ParameterNotFoundError struct{ Name string }

func (*ParameterNotFoundError) Error

func (e *ParameterNotFoundError) Error() string

type SetParameterError

type SetParameterError struct {
	Name string
	Err  error
}

func (*SetParameterError) Error

func (e *SetParameterError) Error() string

func (*SetParameterError) Unwrap

func (e *SetParameterError) Unwrap() error

type Transform

type Transform string
const (
	JSON   Transform = "json"
	Binary Transform = "binary"
	Auto   Transform = "auto"
)

type TransformParameterError

type TransformParameterError struct {
	Transform Transform
	Err       error
}

func (*TransformParameterError) Error

func (e *TransformParameterError) Error() string

func (*TransformParameterError) Unwrap

func (e *TransformParameterError) Unwrap() error

Directories

Path Synopsis
Package appconfig retrieves configuration through the AppConfig Data API.
Package appconfig retrieves configuration through the AppConfig Data API.
Package appconfigagent reads the local AppConfig Agent or Lambda extension.
Package appconfigagent reads the local AppConfig Agent or Lambda extension.
Package dynamodb retrieves configuration values from a DynamoDB table.
Package dynamodb retrieves configuration values from a DynamoDB table.
internal
parameterdefaults
Package parameterdefaults manages lazily initialized default providers.
Package parameterdefaults manages lazily initialized default providers.
Package secrets retrieves AWS Secrets Manager values with an in-memory cache.
Package secrets retrieves AWS Secrets Manager values with an in-memory cache.
Package ssm retrieves and writes AWS Systems Manager parameters.
Package ssm retrieves and writes AWS Systems Manager parameters.

Jump to

Keyboard shortcuts

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