watcher

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRegistered will be returned when watcher is already been registered.
	ErrRegistered = errors.New("watcher has already been registered")
	// ErrConfigUnavailable will be returned when the configuration input is not the expected type.
	ErrConfigUnavailable = errors.New("configuration is not available")
)

Functions

func ListWatchers

func ListWatchers() map[string]IWatcher

ListWatchers returns registered watchers in map format.

func Register

func Register(name string, watcher IWatcher)

Register registers a watcher and save in global variable `registry`.

func Unregister

func Unregister(name string)

Unregister removes a watcher from the registry. The watcher should have stopped.

Types

type IWatcher

type IWatcher interface {
	Init(ctx context.Context, rs *redsync.Mutex, config interface{}) error
	Spec() string
	cron.Job
}

IWatcher is the interface for watchers.

func FindMonitor

func FindMonitor(name string) IWatcher

FindMonitor looks up a watcher in the registry. If not found, nil is returned.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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