watch

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddWatcher

func AddWatcher(cache emoji.Entertainer, file string, opts ...Option) error

AddWatcher initializes a file watcher on the given file.

If the file changes, the Entertainer cache will be reloaded from this file. The file will be watched in a separate go routine.

Use WithDeadline to pass a context which will signal the go routine to free any resources it holds and terminate. By default, context.Background() will be used.

Use WithLogger to receive any log messages from the file watcher. Log messages during the Reload will be reported by the emoji cache.

Types

type ErrInvalidParameters

type ErrInvalidParameters struct{}

ErrInvalidParameters represents the error for passing invalid parameters.

func (*ErrInvalidParameters) Error

func (e *ErrInvalidParameters) Error() string

Error implements the Error interface.

type Option

type Option func(w *watcher)

Option represents the function signature for options when instantiating an emoji file-watcher.

func WithDeadline

func WithDeadline(ctx context.Context) Option

WithDeadline adds a context which DOne signal will trigger the file-watcher go routine to clean up orderly and terminate.

func WithLogger

func WithLogger(logger emoji.Logger) Option

WithLogger adds a basic Logger interface for reporting info & error messages from the file-watcher.

Jump to

Keyboard shortcuts

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