Documentation
¶
Index ¶
- func FormatInterval(d time.Duration) string
- func ParseInterval(s string) (time.Duration, error)
- type Scheduler
- type SiteState
- type SiteStatus
- type StateManager
- func (m *StateManager) GetAllSiteStates() map[string]SiteState
- func (m *StateManager) GetNextRunTime(siteKey string, interval time.Duration) time.Time
- func (m *StateManager) GetSiteState(siteKey string) (SiteState, bool)
- func (m *StateManager) Load() error
- func (m *StateManager) Save() error
- func (m *StateManager) ShouldRun(siteKey string, interval time.Duration) bool
- func (m *StateManager) UpdateSiteState(siteKey string, success bool, pagesProcessed int64, errorMsg string)
- type WatchState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatInterval ¶
FormatInterval formats a duration for display
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
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 ¶
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) 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