config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultWatchMethod   = WatchMethodPolling
	DefaultWatchInterval = 100 * time.Millisecond

	DefaultWatchFileRecursive bool = true

	DefaultWatchFilterScope        = WatchFilterScopeFilename
	DefaultWatchFilterInclude bool = true
	DefaultWatchFilterType         = WatchFilterTypeRegex

	DefaultRateLimitStrategy               = RateLimitStrategyNone
	DefaultRateLimitWait     time.Duration = 0

	DefaultKillSignal                = syscall.SIGTERM
	DefaultKillTimeout time.Duration = 0
)

Variables

View Source
var (
	ErrConfiguratorAlreadyRegistered = errors.New("a configurator has been already registered")
	ErrNoRegisteredConfigurator      = errors.New("no configurator has been registered")
)
View Source
var (
	DefaultWatcher = Watcher{
		Name:      "",
		Watch:     DefaultWatch,
		RateLimit: DefaultRateLimit,
		Kill:      DefaultKill,
		Command:   DefaultCommand,
	}

	DefaultCommand = Command{
		Shell: "/bin/sh -c",
		Path:  ".",
		Env:   os.Environ(),
		Exec:  "",
	}

	DefaultWatch = Watch{
		Method:   DefaultWatchMethod,
		Interval: DefaultWatchInterval,
		Files:    nil,
		Filters:  nil,
	}

	DefaultWatchFile = WatchFile{
		Path:      "",
		Recursive: DefaultWatchFileRecursive,
	}

	DefaultWatchFilter = WatchFilter{
		On:      DefaultWatchFilterScope,
		Include: DefaultWatchFilterInclude,
		Type:    DefaultWatchFilterType,
		List:    nil,
	}

	DefaultRateLimit = RateLimit{
		Strategy: DefaultRateLimitStrategy,
		Wait:     DefaultRateLimitWait,
	}

	DefaultKill = Kill{
		Signal:  DefaultKillSignal,
		Timeout: DefaultKillTimeout,
	}
)

Functions

func Register

func Register(cfr Configurator)

Types

type Command added in v1.1.0

type Command struct {
	Shell string   `json:"shell"`
	Exec  string   `json:"exec"`
	Path  string   `json:"path"`
	Env   []string `json:"env"`
}

type Config

type Config struct {
	Watchers []Watcher `json:"watchers"`
}

func Load

func Load() (*Config, error)

func MustLoad

func MustLoad() *Config

type Configurator

type Configurator interface {
	Load() (*Config, error)
}

type Kill

type Kill struct {
	Signal  os.Signal     `json:"signal"`
	Timeout time.Duration `json:"timeout"`
}

type RateLimit

type RateLimit struct {
	Strategy RateLimitStrategy `json:"strategy"`
	Wait     time.Duration     `json:"wait"`
}

type RateLimitStrategy

type RateLimitStrategy string
const (
	RateLimitStrategyNone     RateLimitStrategy = "none"
	RateLimitStrategyDebounce RateLimitStrategy = "debounce"
	RateLimitStrategyThrottle RateLimitStrategy = "throttle"
	RateLimitStrategyAudit    RateLimitStrategy = "audit"
	RateLimitStrategySample   RateLimitStrategy = "sample"
)

type Watch

type Watch struct {
	Method   WatchMethod   `json:"method"`
	Interval time.Duration `json:"interval"`
	Files    []WatchFile   `json:"files"`
	Filters  []WatchFilter `json:"filters"`
}

type WatchFile

type WatchFile struct {
	Path      string `json:"path"`
	Recursive bool   `json:"recursive"`
}

type WatchFilter

type WatchFilter struct {
	On      WatchFilterScope `json:"on"`
	Include bool             `json:"include"`
	Type    WatchFilterType  `json:"type"`
	List    []string         `json:"list"`
}

type WatchFilterScope

type WatchFilterScope string
const (
	WatchFilterScopeFilename  WatchFilterScope = "filename"
	WatchFilterScopeOperation WatchFilterScope = "operation"
)

type WatchFilterType

type WatchFilterType string
const (
	WatchFilterTypeRegex WatchFilterType = "regex"
	WatchFilterTypeList  WatchFilterType = "list"
)

type WatchMethod

type WatchMethod string
const (
	WatchMethodPolling  WatchMethod = "polling"
	WatchMethodFsnotify WatchMethod = "fsnotify"
)

type Watcher

type Watcher struct {
	Name      string    `json:"name"`
	Watch     Watch     `json:"watch"`
	RateLimit RateLimit `json:"rateLimit"`
	Kill      Kill      `json:"kill"`
	Command   Command   `json:"cmd"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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