watch

package
v0.2.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger interface {
	cron.Logger
	// Debug logs a debug message with optional key-value pairs.
	Debug(msg string, keysAndValues ...interface{})
}

Logger is an interface that extends the cron.Logger interface. It provides an additional method for logging debug messages.

This interface allows implementing custom logging behaviors while maintaining compatibility with the cron package's logging requirements. Implementations of this interface should provide the capability to log standard messages, as defined in the cron.Logger interface, as well as a method to log debug messages with optional key-value pairs for structured logging.

type Option

type Option func(w *Watch)

Option configures a Watch instance with customizable settings.

func WithInitialize

func WithInitialize(initialize initializer.WatcherInitializer) Option

WithInitialize returns an Option function that sets the provided WatcherInitializer function to initialize the Watch during its creation.

func WithLogger

func WithLogger(logger Logger) Option

WithLogger returns an Option function that sets the provided Logger to the Watch for logging purposes.

type Options

type Options struct {
	// LockName specifies the name of the lock used by the server.
	LockName string `json:"lock-name" mapstructure:"lock-name"`

	// healthzPort is the port number for the health check endpoint.
	HealthzPort int `json:"healthz-port" mapstructure:"healthz-port"`

	// DisableWatchers is a slice of watchers that will be disabled when the server is run.
	DisableWatchers []string `json:"disable-watchers" mapstructure:"disable-watchers"`

	// MaxWorkers defines the maximum number of concurrent workers that each watcher can spawn.
	MaxWorkers int64 `json:"max-workers" mapstructure:"max-workers"`
}

Options structure holds the configuration options required to create and run a watch server.

func NewOptions

func NewOptions() *Options

NewOptions initializes and returns a new Options instance with default values.

func (*Options) AddFlags

func (o *Options) AddFlags(fs *pflag.FlagSet)

AddFlags adds the command-line flags associated with the Options structure to the provided FlagSet. This will allow users to configure the watch server via command-line arguments.

func (*Options) Validate

func (o *Options) Validate() []error

Validate checks the Options structure for required configurations and returns a slice of errors.

type Watch

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

Watch represents a monitoring system that schedules and runs tasks at specified intervals.

func NewWatch

func NewWatch(opts *Options, db *gorm.DB, withOptions ...Option) (*Watch, error)

NewWatch creates a new Watch monitoring system with the provided options.

func (*Watch) Start

func (w *Watch) Start(stopCh <-chan struct{})

Start attempts to acquire a distributed lock and starts the Cron job scheduler. It retries acquiring the lock until successful.

func (*Watch) Stop

func (w *Watch) Stop()

Stop blocks until all jobs are completed and releases the distributed lock.

Directories

Path Synopsis
logger

Jump to

Keyboard shortcuts

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