watcher

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package watcher provides functions used by all watchers.

Index

Constants

View Source
const (
	Every3Seconds = "@every 3s"
)

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]Watcher

ListWatchers returns registered watchers in map format.

func Register

func Register(watcher Watcher)

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

Types

type Config

type Config struct {
	// The purpose of nightwatch is to handle asynchronous tasks on the onex platform
	// in a unified manner, so a store aggregation type is needed here.
	Store store.Interface

	// Client is the client for onex-apiserver.
	Client clientset.Interface
}

Config aggregates the configurations of all watchers and serves as a configuration aggregator.

type ISpec

type ISpec interface {
	// Spec return the spec for a cron job.
	// There are two cron spec formats in common usage:
	// - standard cron format: https://en.wikipedia.org/wiki/Cron
	// - quartz scheduler format: http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/tutorial-lesson-06.html
	// This method is optional for a watcher.
	Spec() string
}

Spec interface provides methods to set spec for a cron job.

type Watcher

type Watcher interface {
	Init(ctx context.Context, config *Config) error
	cron.Job
}

Watcher is the interface for watchers. It use cron job as a scheduling engine.

Directories

Path Synopsis
Package clean is a watcher implement.
Package clean is a watcher implement.
Package secretsclean is a watcher implement used to delete expired keys from the database.
Package secretsclean is a watcher implement used to delete expired keys from the database.

Jump to

Keyboard shortcuts

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