engine

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type Config

type Config struct {
	RootPath    string `toml:"root_path"`
	PreExec     string `toml:"pre_exec"`
	ExecCommand string `toml:"exec_command"`
	PostExec    string `toml:"post_exec"`
	// Ignore uses a custom unmarshaler see ignore.go
	Ignore       Ignore `toml:"ignore"`
	LogLevel     string `toml:"log_level"`
	Debounce     int    `toml:"debounce"`
	Callback     func(*EventCallback) EventHandle
	Slog         *slog.Logger
	ExternalSlog bool
}

type Engine

type Engine struct {
	Process        *process.Process
	Chan           chan notify.EventInfo
	Active         bool
	Config         Config `toml:"config"`
	ProcessLogFile *os.File
	ProcessLogPipe io.ReadCloser
}

func NewEngine

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

func NewEngineFromConfig

func NewEngineFromConfig(options Config) *Engine

func NewEngineFromTOML

func NewEngineFromTOML(confPath string) *Engine

func (*Engine) Start

func (engine *Engine) Start()

func (*Engine) Stop

func (engine *Engine) Stop()

type Event

type Event int
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
)

Event is used to determine what type of event was triggered

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 added in v0.0.25

type EventHandle int
const (
	EventContinue EventHandle = iota
	EventBypass
	EventIgnore
)

EventHandle is used to determine how to handle a reload callback

type EventInfo

type EventInfo struct {
	Name   string
	Reload bool
}

type Ignore

type Ignore struct {
	Dir       map[string]bool `toml:"dir"`
	File      map[string]bool `toml:"file"`
	Extension map[string]bool `toml:"extension"`
}

func (*Ignore) UnmarshalTOML

func (i *Ignore) UnmarshalTOML(data interface{}) error

Custom Unmarshal to stuff data into maps

Jump to

Keyboard shortcuts

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