watcher

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWatchCreateExistingFile = errors.New("Cannot watch for creation of a file that already exists")
)

Functions

This section is empty.

Types

type Cron

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

Cron is a decorator of the cron lib this allows the `HandleFunc(config.Condition)` pattern to be established widely throughout the architecture

func NewCron

func NewCron() *Cron

NewCron constructs a new cron schedule watcher

func (*Cron) HandleFunc

func (cron *Cron) HandleFunc(condition *config.Cron, handler func()) error

HandleFunc registers a function to be executed when the provided condition is met.

func (*Cron) Run

func (cron *Cron) Run()

Run starts the cron watcher on its own goroutine

func (*Cron) Stop

func (cron *Cron) Stop(ctx context.Context) error

Stop shuts down the cron watcher and attempts to wait for any currently running functions attached to the scheduler to exit before the provided context is done.

type File

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

func NewFile

func NewFile(logger logrus.FieldLogger) *File

func (*File) HandleFunc

func (f *File) HandleFunc(condition *config.File, handler func()) error

HandleFunc registers the provided function to be executed, when the provided condition has been satisfied. An error is returned if the provided condition is not logically complete

func (*File) Run

func (file *File) Run(pollingInterval time.Duration) error

func (*File) Stop

func (file *File) Stop(ctx context.Context) error

type Process

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

func NewProcess

func NewProcess(logger logrus.FieldLogger) *Process

func (*Process) HandleFunc

func (p *Process) HandleFunc(config *config.Process, f func())

func (*Process) Run

func (p *Process) Run() error

func (*Process) Stop

func (proc *Process) Stop(ctx context.Context) error

Stop signals to the main goroutine to halt processing and exit this method also waits for the main goroutine to signal that it has successfully closed. If `Process` is already stopped then this noops

type Processes

type Processes func() ([]ps.Process, error)

type State

type State uint32
const (
	Open State = iota
	Close
)

Op

Jump to

Keyboard shortcuts

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