Documentation
¶
Overview ¶
Package feed reads the estate feed, projects.json, which is canon for which sources the bot may index (spec 0034).
The feed is fetched once per discovery run. A copy that fetched and parsed is stored, and used whenever a later fetch fails, however old it is (D8, D13): a feed outage never shrinks the corpus.
Index ¶
Constants ¶
const DefaultURL = "https://phpboyscout.uk/projects.json"
DefaultURL is where the estate publishes the feed.
const MaxBytes = 1 << 20
MaxBytes bounds a fetched or stored feed. It is about 66 KB today.
Variables ¶
var ( // ErrSchema is a feed whose schema_version this package does not understand. ErrSchema = errors.NewSentinel("feed.schema", "feed: unsupported schema_version") // ErrTooLarge is a feed over MaxBytes. ErrTooLarge = errors.NewSentinel("feed.too_large", "feed: body over the size bound") // ErrNotHTTPS is a feed URL that is not HTTPS. ErrNotHTTPS = errors.NewSentinel("feed.not_https", "feed: the URL must be HTTPS") )
Functions ¶
Types ¶
type Option ¶
type Option func(*Resolver)
Option configures a Resolver.
func WithClient ¶
WithClient replaces the hardened default client, for tests.
func WithLogger ¶
WithLogger sets where a failed fetch and a stale copy are reported.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver supplies discovery with the feed for each run.
func NewResolver ¶
NewResolver reads the feed from rawURL, which must be HTTPS, keeping the last good copy in store.
type Store ¶
type Store interface {
SaveFeed(ctx context.Context, s Stored) error
LoadFeed(ctx context.Context) (Stored, bool, error)
}
Store keeps the last good copy, in the database's one-row feed table (D8).