watcher

package
v0.0.0-...-55749b9 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxItemContentSize = 5 * 1024 * 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CrawlerPool

type CrawlerPool interface {
	Submit(crawler.CrawlRequest)
}

CrawlerPool defines the interface for submitting crawl requests.

type MailerPool

type MailerPool interface {
	Submit(mailer.MailRequest)
}

MailerPool defines the interface for submitting mail requests.

type Registry

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

Registry manages multiple watchers and routes crawl responses.

func NewRegistry

func NewRegistry(c *crawler.Pool, logger *slog.Logger) *Registry

NewRegistry creates a new watcher registry.

func (*Registry) GetActiveFeedIDs

func (r *Registry) GetActiveFeedIDs() []int64

GetActiveFeedIDs returns a list of all currently registered feed IDs.

func (*Registry) GetWatcher

func (r *Registry) GetWatcher(feedID int64) (*Watcher, bool)

GetWatcher retrieves a watcher by feed ID.

func (*Registry) Register

func (r *Registry) Register(w *Watcher)

Register adds a watcher to the registry.

func (*Registry) Start

func (r *Registry) Start(ctx context.Context)

Start starts the response router loop.

func (*Registry) Unregister

func (r *Registry) Unregister(feedID int64)

Unregister removes a watcher from the registry.

type Watcher

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

Watcher manages the polling of a single feed.

func New

func New(feed models.Feed, store db.Store, c CrawlerPool, m MailerPool, interval, jitter time.Duration, logger *slog.Logger) *Watcher

New creates a new feed watcher.

func (*Watcher) Feed

func (w *Watcher) Feed() models.Feed

Feed returns the feed model associated with the watcher.

func (*Watcher) FormatItem

func (w *Watcher) FormatItem(feedTitle string, item *gofeed.Item) (subject, body string)

FormatItem sanitizes and formats a feed item for an email.

func (*Watcher) HandleResponse

func (w *Watcher) HandleResponse(ctx context.Context, resp crawler.CrawlResponse)

HandleResponse processes a crawl result. This is called by the orchestrator which listens to the crawler pool.

func (*Watcher) Run

func (w *Watcher) Run(ctx context.Context)

Run starts the watcher loop.

func (*Watcher) Stop

func (w *Watcher) Stop()

Stop cancels the watcher loop.

Jump to

Keyboard shortcuts

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