riviera: hawx.me/code/riviera/feed Index | Files | Directories

package feed

import "hawx.me/code/riviera/feed"

Package feed provides a feed fetcher capable of reading multiple formats into a common structure.


Package Files

database.go feed.go

type Database Uses

type Database interface {
    Contains(string) bool

A Database allows the Feed to keep track of items it has already seen before.

func NewDatabase Uses

func NewDatabase() Database

NewDatabase returns an empty in-memory database for item keys.

type Feed Uses

type Feed struct {
    // contains filtered or unexported fields

func New Uses

func New(cachetimeout time.Duration, ih ItemHandler, database Database) *Feed

func (*Feed) CanUpdate Uses

func (f *Feed) CanUpdate() bool

This function returns true or false, depending on whether the CacheTimeout value has expired or not. Additionally, it will ensure that we adhere to the RSS spec's SkipDays and SkipHours values. If this function returns true, you can be sure that a fresh feed update will be performed.

func (*Feed) DurationTillUpdate Uses

func (f *Feed) DurationTillUpdate() time.Duration

Returns the number of seconds needed to elapse before the feed should update.

func (*Feed) Fetch Uses

func (f *Feed) Fetch(uri string, client *http.Client, charset func(charset string, input io.Reader) (io.Reader, error)) (status int, err error)

Fetch retrieves the feed's latest content if necessary.

The charset parameter overrides the xml decoder's CharsetReader. This allows us to specify a custom character encoding conversion routine when dealing with non-utf8 input. Supply 'nil' to use the default from Go's xml package.

The client parameter allows the use of arbitrary network connections, for example the Google App Engine "URL Fetch" service.

If the feed is unable to update (see CanUpdate) then no request will be made, instead the result will be (status=-1, err=nil).

type ItemHandler Uses

type ItemHandler func(f *Feed, ch *common.Channel, newitems []*common.Item)


atomPackage atom provides a parser for Atom feeds.
rdfPackage rdf provides a parser for RDF Site Summary (RSS) 1.0.
rssPackage rss provides a parser for RSS v2.0 feeds.

Package feed imports 12 packages (graph) and is imported by 7 packages. Updated 2018-01-16. Refresh now. Tools for package owners.