engine

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EventMap = map[notify.Event]eventInfo{
	notify.InCloseWrite: {Name: "InCloseWrite", Reload: true},
	notify.InModify:     {Name: "InModify", Reload: true},
	notify.InMovedTo:    {Name: "InMovedTo", Reload: true},
	notify.InMovedFrom:  {Name: "InMovedFrom", Reload: true},
	notify.InCreate:     {Name: "InCreate", Reload: true},
	notify.InDelete:     {Name: "InDelete", Reload: true},
	notify.Write:        {Name: "Write", Reload: true},
	notify.Create:       {Name: "Create", Reload: false},
	notify.Remove:       {Name: "Remove", Reload: false},
	notify.Rename:       {Name: "Rename", Reload: false},
}

Functions

This section is empty.

Types

type Config

type Config struct {
	RootPath           string            `toml:"root_path" yaml:"root_path"`
	BackgroundStruct   process.Execute   `toml:"background" yaml:"background"`
	BackgroundCallback func() bool       `toml:"-" yaml:"-"`
	Ignore             Ignore            `toml:"ignore" yaml:"ignore"`
	ExecStruct         []process.Execute `toml:"executes" yaml:"executes"`
	ExecList           []string          `toml:"exec_list" yaml:"exec_list"`
	LogLevel           string            `toml:"log_level" yaml:"log_level"`
	Debounce           int               `toml:"debounce" yaml:"debounce"`
	Callback           func(*EventCallback) EventHandle
	Slog               *slog.Logger
	// contains filtered or unexported fields
}

type Engine

type Engine struct {
	PrimaryProcess process.Process
	BgProcess      process.Process
	Chan           chan notify.EventInfo
	Active         bool
	Config         Config `toml:"config" yaml:"config"`
	ProcessLogFile *os.File
	ProcessLogPipe io.ReadCloser
	ProcessManager *process.ProcessManager
	// contains filtered or unexported fields
}

func NewEngine

func NewEngine(rootPath, execCommand, logLevel string, execList []string, ignore Ignore, debounce int, chunkSize string) (*Engine, error)

This is out of date

func NewEngineFromConfig

func NewEngineFromConfig(options Config) (*Engine, error)

func NewEngineFromTOML

func NewEngineFromTOML(confPath string) (*Engine, error)

func NewEngineFromYAML added in v0.4.1

func NewEngineFromYAML(confPath string) (*Engine, error)

func (*Engine) AttachBackgroundCallback added in v0.4.4

func (engine *Engine) AttachBackgroundCallback(callback func() bool) *Engine

func (*Engine) SetLogger added in v0.4.0

func (engine *Engine) SetLogger(logger *slog.Logger)

func (*Engine) Start

func (engine *Engine) Start() error

func (*Engine) Stop

func (engine *Engine) Stop()

func (*Engine) StringtoConfigTOML added in v0.4.8

func (engine *Engine) StringtoConfigTOML(tomlString string) error

func (*Engine) StringtoConfigYAML added in v0.4.8

func (engine *Engine) StringtoConfigYAML(yamlString string) error

type Event

type Event int

Event is used to determine what type of event was triggered

const (
	Create Event = iota
	Write
	Remove
	Rename
	// Windows Specific Actions
	ActionModified
	ActionRenamedNewName
	ActionRenamedOldName
	ActionAdded
	ActionRemoved
	ChangeLastWrite
	ChangeAttributes
	ChangeSize
	ChangeDirName
	ChangeFileName
	ChangeSecurity
	ChangeCreation
	ChangeLastAccess
	// Linux Specific Actions
	InCloseWrite
	InModify
	InMovedTo
	InMovedFrom
	InCreate
	InDelete
)

type EventCallback

type EventCallback struct {
	Type Event     // Event enum
	Time time.Time // time.Now() when event was triggered
	Path string    // Full path to the modified file
}

Called whenever a change is detected in the filesystem By default we ignore file rename/remove and a bunch of other events that would likely cause breaking changes on a reload see eventmap_[oos].go for default rules

type EventHandle

type EventHandle int

EventHandle is used to determine how to handle a reload callback

const (
	EventContinue EventHandle = iota
	EventBypass
	EventIgnore
)

type EventManager added in v0.6.0

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

func NewEventManager added in v0.6.0

func NewEventManager(engine *Engine, debounce int) *EventManager

func (*EventManager) HandleEvent added in v0.6.0

func (em *EventManager) HandleEvent(ei notify.EventInfo)

type Ignore

type Ignore struct {
	Dir          []string `toml:"dir" yaml:"dir"`
	File         []string `toml:"file" yaml:"file"`
	WatchedExten []string `toml:"watched_extension" yaml:"watched_extension"`
	IgnoreGit    bool     `toml:"git" yaml:"git"`
}

Jump to

Keyboard shortcuts

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