fileobserver

package
v0.0.0-...-73e1fb8 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExitOnChangeReactor = TerminateOnChangeReactor(func() { os.Exit(0) })

ExitOnChangeReactor provides reactor function that causes the process to exit when the change is detected. DEPRECATED: Using this function cause process to exit immediately without proper shutdown (context close/etc.)

Use the TerminateOnChangeReactor() instead.

Functions

This section is empty.

Types

type ActionType

type ActionType int

ActionType define a type of action observed on the file

const (
	// FileModified means the file content was modified.
	FileModified ActionType = iota

	// FileCreated means the file was just created.
	FileCreated

	// FileDeleted means the file was deleted.
	FileDeleted
)

func (ActionType) String

func (t ActionType) String(filename string) string

String returns human readable form of action taken on a file.

type Observer

type Observer interface {
	Run(stopChan <-chan struct{})
	HasSynced() bool
	AddReactor(reaction ReactorFn, startingFileContent map[string][]byte, files ...string) Observer
}

func NewObserver

func NewObserver(interval time.Duration) (Observer, error)

type ReactorFn

type ReactorFn func(file string, action ActionType) error

ReactorFn define a reaction function called when an observed file is modified.

func TerminateOnChangeReactor

func TerminateOnChangeReactor(terminateFn func()) ReactorFn

Jump to

Keyboard shortcuts

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