settings

package
v0.0.0-...-cb5decc Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("setting not found")
View Source
var ItemMap = make(map[string]UpdateableItem)

Functions

func ClearCache

func ClearCache()

func GetDefaultValue

func GetDefaultValue[T any](key string, defaultValue T) T

func Group

func Group(key, name string, f func())

func InitStore

func InitStore(s Store)

func MockInit

func MockInit()

func MockReset

func MockReset()

Types

type DAO

type DAO struct {
	stdao.Std[*Model]
}

func InitDAO

func InitDAO(db *gorm.DB) (*DAO, error)

func (*DAO) GetByKey

func (o *DAO) GetByKey(ctx context.Context, key string) (*Model, error)

func (*DAO) UpdateOrCreate

func (o *DAO) UpdateOrCreate(ctx context.Context, s *Model) error

type GroupInfo

type GroupInfo struct {
	Path       string `json:"path"`
	Label      string `json:"label"`
	GroupOrder int    `json:"order"`

	Children []any `json:"children"`
	// contains filtered or unexported fields
}

func Root

func Root() *GroupInfo

func (*GroupInfo) Init

func (o *GroupInfo) Init()

func (*GroupInfo) Order

func (o *GroupInfo) Order() int

func (*GroupInfo) SortChildren

func (o *GroupInfo) SortChildren()

type Item

type Item[T any] struct {
	Label string `json:"label"`
	Key   string `json:"key"`

	ItemOrder    int `json:"order"`
	CurrValue    T   `json:"value"`
	DefaultValue T   `json:"defaultValue"`
	// contains filtered or unexported fields
}

func NewItem

func NewItem[T any](key, label string, defaultValue T) *Item[T]

func NewItemWithGroupAndOrder

func NewItemWithGroupAndOrder[T any](key, label, group string, order int, defaultValue T) *Item[T]

func (*Item[T]) AfterUpdateHook

func (o *Item[T]) AfterUpdateHook(f func())

func (*Item[T]) Init

func (o *Item[T]) Init()

func (*Item[T]) Order

func (o *Item[T]) Order() int

func (*Item[T]) Update

func (o *Item[T]) Update(v T) error

func (*Item[T]) UpdateValueBytes

func (o *Item[T]) UpdateValueBytes(v []byte) error

func (*Item[T]) Value

func (o *Item[T]) Value() T

func (*Item[T]) ValueBytes

func (o *Item[T]) ValueBytes() []byte

type Model

type Model struct {
	Key   string `gorm:"primaryKey;size:255;not null"`
	Value datatypes.JSON
	Order int
}

func (Model) TableName

func (Model) TableName() string

type Record

type Record struct {
	Key   string
	Value []byte
	Order int
}

type Store

type Store interface {
	GetByKey(ctx context.Context, key string) (*Record, error)
	UpdateOrCreate(ctx context.Context, record *Record) error
}

type UpdateableItem

type UpdateableItem interface {
	ValueBytes() []byte
	UpdateValueBytes([]byte) error
}

Jump to

Keyboard shortcuts

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