config

package
v0.10.4 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigData

type ConfigData[T any] struct {
	FilePath string
	Sections map[string]*Section[T]
	Order    []string
}

ConfigData holds all sections and their ordering

type ConfigTag added in v0.9.6

type ConfigTag struct {
	Type      PropertyType
	Key       string
	Required  bool
	MinLength *int
	MaxLength *int
	IsID      bool // New field to mark which field is the section ID
}

ConfigTag represents the parsed configuration tags from struct fields

type FileMutexManager added in v0.9.2

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

func NewFileMutexManager added in v0.9.2

func NewFileMutexManager() *FileMutexManager

func (*FileMutexManager) WithReadLock added in v0.9.2

func (fm *FileMutexManager) WithReadLock(path string, fn func() error) error

func (*FileMutexManager) WithWriteLock added in v0.9.2

func (fm *FileMutexManager) WithWriteLock(path string, fn func() error) error

type PropertyType

type PropertyType string

PropertyType represents the type of a configuration property

const (
	TypeString PropertyType = "string"
	TypeInt    PropertyType = "int"
	TypeBool   PropertyType = "bool"
	TypeArray  PropertyType = "array"
	TypeObject PropertyType = "object"
)

type Section

type Section[T any] struct {
	Type       string
	ID         string
	Properties T
}

Section represents a single configuration section

type SectionConfig

type SectionConfig[T any] struct {
	// contains filtered or unexported fields
}

func NewSectionConfig

func NewSectionConfig[T any](plugin *SectionPlugin[T]) *SectionConfig[T]

func (*SectionConfig[T]) Parse

func (sc *SectionConfig[T]) Parse(filename string) (*ConfigData[T], error)

Parse reads and parses a configuration file

func (*SectionConfig[T]) Write

func (sc *SectionConfig[T]) Write(config *ConfigData[T]) error

type SectionPlugin

type SectionPlugin[T any] struct {
	TypeName   string
	IDProperty string
	Validate   func(T) error
	FolderPath string
}

SectionPlugin defines the schema and behavior for a specific section type

Jump to

Keyboard shortcuts

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