loader

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: MIT, Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ReloadTypeNoneName     = "none"
	ReloadTypeFsNotifyName = "fsnotify"
	ReloadTypeTimerName    = "timer"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Loader

type Loader struct {
	// 间隔大于1秒采用timer定时加载,小于1秒用fsnotify
	ReloadInterval time.Duration `comment:"0:not reload; < 1s: fsnotify; >= 1s: polling"`
	Paths          []string
	// contains filtered or unexported fields
}

func New

func New(interval time.Duration, filepaths ...string) *Loader

New initialize a Loader

func (*Loader) Add added in v0.10.4

func (ld *Loader) Add(paths ...string) error

func (*Loader) Close added in v0.10.4

func (ld *Loader) Close() error

func (*Loader) Handle

func (ld *Loader) Handle(handle func(io.Reader) error) (err error)

Load will unmarshal configurations to struct from files that you provide

func (*Loader) Remove added in v0.10.4

func (ld *Loader) Remove(paths ...string) error

type ReloadType

type ReloadType int
const (
	ReloadTypeNone ReloadType = iota
	ReloadTypeFsNotify
	ReloadTypeTimer
)

func (ReloadType) MarshalJSON added in v0.8.0

func (t ReloadType) MarshalJSON() ([]byte, error)

func (ReloadType) MarshalText added in v0.8.0

func (t ReloadType) MarshalText() ([]byte, error)

func (ReloadType) String added in v0.8.0

func (t ReloadType) String() string

func (*ReloadType) UnmarshalJSON added in v0.8.0

func (t *ReloadType) UnmarshalJSON(data []byte) error

func (*ReloadType) UnmarshalText added in v0.8.0

func (t *ReloadType) UnmarshalText(data []byte) error

Jump to

Keyboard shortcuts

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