watchgod

package
v0.0.0-...-12a582f Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultInfoCheckPoint         = 100
	DefaultCrawlerMaxErrThreshold = 20

	// Monitorable Defaults
	DefaultWindowLength        = 5
	DefaultMaxErrThreshold     = 4
	DefaultMonitorableInterval = 45 * time.Second
)
View Source
const (
	DefaultMaxSize = 100
)

Variables

View Source
var (
	ErrMaxSizeLessThan0 = errors.New("max size must be > 0")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxSize     int
	Monitorable []json.RawMessage
}

func NewDefaultConfig

func NewDefaultConfig() *Config

func (Config) HydratedWithDefaults

func (c Config) HydratedWithDefaults() (*Config, error)

func (Config) ReadMaxSize

func (c Config) ReadMaxSize() (int, error)

type Crawler

type Crawler struct {
	sync.Mutex

	Monitorable []*Monitorable

	InfoCheckPoint  int
	ErrCount        int
	MaxErrThreshold int

	EventChan chan (Monitorable)
	ErrChan   chan (error)
	Finished  chan (bool)
	// contains filtered or unexported fields
}

func NewCrawler

func NewCrawler(ctx context.Context, cfg Config) *Crawler

func NewCrawlerFromConfig

func NewCrawlerFromConfig() *Crawler

func (*Crawler) Add

func (c *Crawler) Add(m *Monitorable) int

func (*Crawler) Remove

func (c *Crawler) Remove(m *Monitorable) bool

func (*Crawler) RemovePosition

func (c *Crawler) RemovePosition(idx int) bool

func (*Crawler) Start

func (c *Crawler) Start()

func (*Crawler) Status

func (c *Crawler) Status() (chan (string), error)

func (*Crawler) Stop

func (c *Crawler) Stop() chan (string)

func (*Crawler) Wait

func (c *Crawler) Wait() chan (bool)

type Monitorable

type Monitorable struct {
	URL             string
	Status          bool
	StatusWindow    []bool
	WindowLength    int
	MaxErrThreshold int
	Interval        time.Duration
	NextCheck       *time.Time
	LastChecked     *time.Time
	Protocol        Protocol
	// contains filtered or unexported fields
}

func NewMonitorable

func NewMonitorable() *Monitorable

func (*Monitorable) AddStatus

func (m *Monitorable) AddStatus(status bool) int

func (*Monitorable) Check

func (m *Monitorable) Check(ctx context.Context) (bool, error)

func (*Monitorable) ErrThresholdExceeded

func (m *Monitorable) ErrThresholdExceeded() bool

func (*Monitorable) ShouldCheck

func (m *Monitorable) ShouldCheck() bool

type Protocol

type Protocol int64
const (
	TCP Protocol = iota
	ICMP
	HTTP
	UDP
)

func (Protocol) String

func (p Protocol) String() string

Jump to

Keyboard shortcuts

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