reload

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const ID = "reload"

ID contains default service name.

Variables

View Source
var ErrorSkip = errors.New("file is skipped")
View Source
var NoWalkerConfig = errors.New("should add at least one walker config, when reload is set to true")

Functions

func ConvertIgnored

func ConvertIgnored(ignored []string) (map[string]struct{}, error)

ConvertIgnored is used to convert slice to map with ignored files

Types

type Config

type Config struct {
	// Interval is a global refresh interval
	Interval time.Duration

	// Patterns is a global file patterns to watch. It will be applied to every directory in project
	Patterns []string

	// Services is set of services which would be reloaded in case of FS changes
	Services map[string]ServiceConfig
}

Config is a Reload configuration point.

func (*Config) Hydrate

func (c *Config) Hydrate(cfg service.Config) error

Hydrate must populate Config values using given Config source. Must return error if Config is not valid.

func (*Config) InitDefaults

func (c *Config) InitDefaults() error

InitDefaults sets missing values to their default values.

func (*Config) Valid

func (c *Config) Valid() error

Valid validates the configuration.

type Event

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

An Event describes an event that is received when files or directory changes occur. It includes the os.FileInfo of the changed file or directory and the type of event that's occurred and the full path of the file.

type Options

type Options func(*Watcher)

Options is used to set Watcher Options

type Service

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

func (*Service) Init

func (s *Service) Init(cfg *Config, log *logrus.Logger, c service.Container) (bool, error)

Init controller service

func (*Service) Serve

func (s *Service) Serve() error

func (*Service) Stop

func (s *Service) Stop()

type ServiceConfig

type ServiceConfig struct {
	// Enabled indicates that service must be watched, doest not required when any other option specified
	Enabled bool

	// Recursive is options to use nested files from root folder
	Recursive bool

	// Patterns is per-service specific files to watch
	Patterns []string

	// Dirs is per-service specific dirs which will be combined with Patterns
	Dirs []string

	// Ignore is set of files which would not be watched
	Ignore []string
	// contains filtered or unexported fields
}

type SimpleHook

type SimpleHook func(filename string, pattern []string) error

SimpleHook is used to filter by simple criteria, CONTAINS

type Watcher

type Watcher struct {
	// main event channel
	Event chan Event
	// contains filtered or unexported fields
}

func NewWatcher

func NewWatcher(configs []WatcherConfig, options ...Options) (*Watcher, error)

NewWatcher returns new instance of File Watcher

func (*Watcher) GetAllFiles

func (w *Watcher) GetAllFiles(serviceName string) []os.FileInfo

GetAllFiles returns all files initialized for particular company

func (*Watcher) StartPolling

func (w *Watcher) StartPolling(duration time.Duration) error

func (*Watcher) Stop

func (w *Watcher) Stop()

type WatcherConfig

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

Jump to

Keyboard shortcuts

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