watch

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatInterval

func FormatInterval(d time.Duration) string

FormatInterval formats a duration for display

func ParseInterval

func ParseInterval(s string) (time.Duration, error)

ParseInterval parses a duration string with support for days

Types

type Scheduler

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

Scheduler manages periodic crawling of sites

func NewScheduler

func NewScheduler(appCfg *config.AppConfig, siteKeys []string, interval time.Duration, log *logrus.Entry) *Scheduler

NewScheduler creates a new watch scheduler

func (*Scheduler) GetStatus

func (s *Scheduler) GetStatus() map[string]SiteStatus

GetStatus returns the current status of all watched sites

func (*Scheduler) Run

func (s *Scheduler) Run() error

Run starts the watch scheduler and blocks until stopped

func (*Scheduler) Stop

func (s *Scheduler) Stop()

Stop stops the watch scheduler

type SiteState

type SiteState struct {
	LastRunTime    time.Time `json:"last_run_time"`
	LastRunSuccess bool      `json:"last_run_success"`
	PagesProcessed int64     `json:"pages_processed"`
	ErrorMessage   string    `json:"error_message,omitempty"`
}

SiteState contains the last run information for a site

type SiteStatus

type SiteStatus struct {
	SiteKey        string
	LastRunTime    time.Time
	LastRunSuccess bool
	PagesProcessed int64
	ErrorMessage   string
	NextRunTime    time.Time
	NeverRun       bool
}

SiteStatus contains the status of a watched site

type StateManager

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

StateManager handles persisting and loading watch state

func NewStateManager

func NewStateManager(stateDir string) *StateManager

NewStateManager creates a new state manager

func (*StateManager) GetAllSiteStates

func (m *StateManager) GetAllSiteStates() map[string]SiteState

GetAllSiteStates returns all site states

func (*StateManager) GetNextRunTime

func (m *StateManager) GetNextRunTime(siteKey string, interval time.Duration) time.Time

GetNextRunTime returns when the site should next run

func (*StateManager) GetSiteState

func (m *StateManager) GetSiteState(siteKey string) (SiteState, bool)

GetSiteState returns the state for a specific site

func (*StateManager) Load

func (m *StateManager) Load() error

Load loads the state from disk

func (*StateManager) Save

func (m *StateManager) Save() error

Save saves the state to disk

func (*StateManager) ShouldRun

func (m *StateManager) ShouldRun(siteKey string, interval time.Duration) bool

ShouldRun checks if a site should run based on the interval

func (*StateManager) UpdateSiteState

func (m *StateManager) UpdateSiteState(siteKey string, success bool, pagesProcessed int64, errorMsg string)

UpdateSiteState updates the state for a specific site

type WatchState

type WatchState struct {
	Sites     map[string]SiteState `json:"sites"`
	UpdatedAt time.Time            `json:"updated_at"`
}

WatchState contains the persistent state for the watch scheduler

Jump to

Keyboard shortcuts

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