overlay

package
v0.2.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Flag

type Flag struct {
	Value      json.RawMessage `json:"value"`
	CreatedAt  time.Time       `json:"created_at"`  //nolint:tagliatelle // JSON file.
	ModifiedAt time.Time       `json:"modified_at"` //nolint:tagliatelle // JSON file.
}

Flag represents one feature-flag record.

type GroupID

type GroupID string

GroupID is the compile-time type for group names stored on disk.

type Key

type Key interface {
	Group() GroupID
	ID() KeyID
}

Key identifies a single flag entry.

type KeyID

type KeyID string

KeyID is the compile-time type for individual entry names.

type Option

type Option func(*Store) error

func WithKeyType

func WithKeyType[K Key]() Option

WithKeyType registers the group of the compile-time key type K.

type Root

type Root map[GroupID]map[KeyID]Flag

Root is the complete in-memory image of the file.

type Store

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

func NewOverlayStore

func NewOverlayStore(ctx context.Context, path string, opts ...Option) (*Store, error)

NewOverlayStore opens (or creates) the SQLite database at the given path. Parent directories are created if missing.

func (*Store) Close added in v0.0.79

func (s *Store) Close() error

Close blocks until any in-flight Get/Set/Delete finishes (they hold s.mu), then closes the underlying *sql.DB exactly once.

func (*Store) DeleteKey

func (s *Store) DeleteKey(ctx context.Context, k Key) error

func (*Store) GetFlag

func (s *Store) GetFlag(ctx context.Context, k Key) (Flag, bool, error)

func (*Store) SetFlag

func (s *Store) SetFlag(ctx context.Context, k Key, val json.RawMessage) (Flag, error)

type TypedFlag

type TypedFlag[ValT any] struct {
	Value      ValT      `json:"value"`
	CreatedAt  time.Time `json:"created_at"`  //nolint:tagliatelle // JSON file.
	ModifiedAt time.Time `json:"modified_at"` //nolint:tagliatelle // JSON file.
}

type TypedGroup

type TypedGroup[K Key, ValT any] struct {
	// contains filtered or unexported fields
}

TypedGroup provides type-safe access to a specific group in the store.

func NewTypedGroup

func NewTypedGroup[K Key, ValT any](
	ctx context.Context,
	store *Store,
) (*TypedGroup[K, ValT], error)

NewTypedGroup creates a typed group accessor - this is the correct way since Go doesn't allow type parameters on struct methods.

func (*TypedGroup[K, ValT]) DeleteKey

func (g *TypedGroup[K, ValT]) DeleteKey(ctx context.Context, k K) error

DeleteKey removes an entry from the group.

func (*TypedGroup[K, ValT]) GetFlag

func (g *TypedGroup[K, ValT]) GetFlag(ctx context.Context, k K) (TypedFlag[ValT], bool, error)

GetFlag retrieves a typed value from the group.

func (*TypedGroup[K, ValT]) SetFlag

func (g *TypedGroup[K, ValT]) SetFlag(
	ctx context.Context,
	k K,
	value ValT,
) (TypedFlag[ValT], error)

SetFlag stores a typed value in the group.

Jump to

Keyboard shortcuts

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