storageconfig

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrProfileNameRequired = errors.New("storageconfig: profile name is required")

ErrProfileNameRequired indicates that profile operations require a non-empty name.

View Source
var ErrProfileNotFound = errors.New("storageconfig: profile not found")

ErrProfileNotFound indicates that a requested storage profile does not exist.

Functions

This section is empty.

Types

type BunRepository

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

BunRepository persists profiles using a Bun-backed database.

func NewBunRepository

func NewBunRepository(db *bun.DB) *BunRepository

NewBunRepository constructs a Bun-backed repository.

func (*BunRepository) Delete

func (r *BunRepository) Delete(ctx context.Context, name string) error

Delete removes a profile by name.

func (*BunRepository) Get

func (r *BunRepository) Get(ctx context.Context, name string) (*storage.Profile, error)

Get retrieves a profile by name.

func (*BunRepository) List

func (r *BunRepository) List(ctx context.Context) ([]storage.Profile, error)

List returns the stored profiles ordered by name.

func (*BunRepository) Subscribe

func (r *BunRepository) Subscribe(ctx context.Context) (<-chan ChangeEvent, error)

Subscribe delivers change events until the context is cancelled.

func (*BunRepository) Upsert

func (r *BunRepository) Upsert(ctx context.Context, profile storage.Profile) (*storage.Profile, error)

Upsert creates or updates a profile.

type ChangeEvent

type ChangeEvent struct {
	Type    ChangeType
	Profile storage.Profile
}

ChangeEvent reports profile mutations to interested subscribers.

type ChangeType

type ChangeType string

ChangeType enumerates storage profile change events.

const (
	// ChangeCreated indicates a new profile was persisted.
	ChangeCreated ChangeType = "created"
	// ChangeUpdated indicates an existing profile was modified.
	ChangeUpdated ChangeType = "updated"
	// ChangeDeleted indicates a profile was removed.
	ChangeDeleted ChangeType = "deleted"
)

type MemoryRepository

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

MemoryRepository stores profiles in-memory for tests and lightweight deployments.

func NewMemoryRepository

func NewMemoryRepository() *MemoryRepository

NewMemoryRepository constructs an empty in-memory repository.

func (*MemoryRepository) Delete

func (r *MemoryRepository) Delete(_ context.Context, name string) error

Delete removes a profile by name.

func (*MemoryRepository) Get

Get retrieves a profile by name.

func (*MemoryRepository) List

List returns the stored profiles ordered by name.

func (*MemoryRepository) Subscribe

func (r *MemoryRepository) Subscribe(ctx context.Context) (<-chan ChangeEvent, error)

Subscribe delivers change events until the context is cancelled.

func (*MemoryRepository) Upsert

func (r *MemoryRepository) Upsert(_ context.Context, profile storage.Profile) (*storage.Profile, error)

Upsert creates or updates a profile.

type Repository

type Repository interface {
	List(ctx context.Context) ([]storage.Profile, error)
	Get(ctx context.Context, name string) (*storage.Profile, error)
	Upsert(ctx context.Context, profile storage.Profile) (*storage.Profile, error)
	Delete(ctx context.Context, name string) error
	Subscribe(ctx context.Context) (<-chan ChangeEvent, error)
}

Repository exposes persistence operations for runtime storage profiles.

Jump to

Keyboard shortcuts

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