fetcher

package
v0.0.0-...-e3797e0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	GetPage(*data.UserPagemonitor) (*data.PagemonitorPage, error)
	SavePage(*data.PagemonitorPage) error
	SaveFeeditems(...*data.Feeditem) (err error)
	SetFetchStatus([]byte, *data.FetchStatus) error
	SetReadStatusForAll(k []byte, read bool) error
	GetUsers() ([]string, error)
	GetUser(username string) (*data.User, error)
}

DB provides functions to read and write items in the database.

type Fetcher

type Fetcher struct {
	DB         DB
	Client     *http.Client
	TagsPolicy *bluemonday.Policy
}

Fetcher contains services needed to fetch items and save them into a database.

func NewFetcher

func NewFetcher(db DB) *Fetcher

NewFetcher creates a new Fetcher instance with db.

func (*Fetcher) FetchAllFeeds

func (fetcher *Fetcher) FetchAllFeeds() error

FetchAllFeeds calls FetchFeed for all feeds for all users.

func (*Fetcher) FetchAllPages

func (fetcher *Fetcher) FetchAllPages() error

FetchAllPages calls FetchPage for all pages for all users.

func (*Fetcher) FetchFeed

func (fetcher *Fetcher) FetchFeed(feedURL string) error

FetchFeed fetches a feed from feedURL and saves it into the database if fetching was successful.

func (*Fetcher) FetchPage

func (fetcher *Fetcher) FetchPage(config *data.UserPagemonitor) error

FetchPage fetches a page and performs a diff based on config. On success, it's saved into the database.

func (*Fetcher) ParseFeed

func (fetcher *Fetcher) ParseFeed(feedURL string, reader io.Reader) ([]*data.Feeditem, error)

ParseFeed parses a downloaded XML feed.

func (*Fetcher) Refresh

func (fetcher *Fetcher) Refresh()

Refresh performs a fetch of all monitored items.

Jump to

Keyboard shortcuts

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