watch

package
v0.0.0-...-d9af1ea Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoParanoia = 0 + iota
	BasicParanoia
	ExtraParanoia
)

Variables

This section is empty.

Functions

func Watch

func Watch(c *Config) error

Start watching the directory in this config. This is a blocking activity so can be wrapped in a goroutine if you want to do other things!

Types

type Action

type Action interface {
	Process(*Watcher, string) bool
}

describes the interface required of a directory action, eg PostAction

type Config

type Config struct {
	Actions              []Action              /* List of actions to perform when new files arrive */
	AfterFileAction      func(filename string) /* Callback to call after a file action */
	ArchiveDir           string                /* If set, place to store files after they have been successfully processed */
	ErrorDir             string                /* If set, place to store files if an action fails */
	Dir                  string                /* Directory to watch */
	ProcessExistingFiles bool                  /* Process pre-existing files on startup */
	Paranoia             ParanoiaLevel         /* Wait and see if file is finished writing */
	Debug                bool                  /* Verbose output */
	ReportActions        bool                  /* Log actions */
	ReportErrors         bool                  /* Error output */
	TestingOptions       []string              /* Misc behaviour flags largely for testing */
	// contains filtered or unexported fields
}

A watcher config: a directory to watch, it's associated actions and any global options

type DummyAction

type DummyAction struct {
	LastFile   string
	FailPlease bool
}

func (*DummyAction) Process

func (a *DummyAction) Process(w *Watcher, file string) bool

type EchoAction

type EchoAction struct {
}

func (*EchoAction) Process

func (a *EchoAction) Process(w *Watcher, file string) bool

type ParanoiaLevel

type ParanoiaLevel int

type PostAction

type PostAction struct {
	To                string
	Mime              string
	BasicAuthUsername string
	BasicAuthPwd      string
}

func (*PostAction) Process

func (a *PostAction) Process(w *Watcher, file string) bool

type RunAction

type RunAction struct {
	Cmd      string
	Args     []string
	PostArgs []string
}

func (*RunAction) Process

func (a *RunAction) Process(w *Watcher, file string) bool

type Watcher

type Watcher struct {
	Config *Config
	// contains filtered or unexported fields
}

An active watcher.

func (*Watcher) Close

func (w *Watcher) Close()

Close the watcher, stop watching!

Jump to

Keyboard shortcuts

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