Documentation
¶
Overview ¶
Package sqlite implements the firehose cache using the pure-Go (no cgo) SQLite driver, modernc.org/sqlite, for portability reasons across various Linux architectures. The cache holds dedupe keys, conditional-GET validators, retention data, and feed-health state — never read state.
Index ¶
- type DB
- type FeedService
- func (s *FeedService) FindFeedByURL(ctx context.Context, url string) (*firehose.Feed, error)
- func (s *FeedService) FindFeeds(ctx context.Context, filter firehose.FeedFilter) ([]*firehose.Feed, int, error)
- func (s *FeedService) SyncFeeds(ctx context.Context, feeds []*firehose.Feed) error
- func (s *FeedService) UpdateFeed(ctx context.Context, id int64, upd firehose.FeedUpdate) (*firehose.Feed, error)
- type ItemService
- func (s *ItemService) FindItems(ctx context.Context, filter firehose.ItemFilter) ([]*firehose.Item, int, error)
- func (s *ItemService) ItemStats(ctx context.Context) ([]firehose.ItemStat, error)
- func (s *ItemService) PurgeExpired(ctx context.Context, olderThan time.Time) (int, error)
- func (s *ItemService) UpsertItems(ctx context.Context, items []*firehose.Item) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
DB wraps a *sql.DB with firehose-specific open/migrate behavior. It also carries the display *time.Location so times read back from the cache are interpreted consistently (SQLite has no native tz; we store UTC and present in the configured location at render time).
type FeedService ¶
type FeedService struct {
// contains filtered or unexported fields
}
FeedService is the SQLite-backed firehose.FeedService.
func NewFeedService ¶
func NewFeedService(db *DB) *FeedService
NewFeedService constructs a FeedService over db.
func (*FeedService) FindFeedByURL ¶
FindFeedByURL returns the feed with the given URL or an ENOTFOUND error.
func (*FeedService) FindFeeds ¶
func (s *FeedService) FindFeeds(ctx context.Context, filter firehose.FeedFilter) ([]*firehose.Feed, int, error)
FindFeeds returns feeds matching filter and the total count (ignoring offset/limit).
func (*FeedService) SyncFeeds ¶
SyncFeeds reconciles the configured feed set into the cache: inserts new feeds, updates categories/config on existing ones (matched by URL), and deletes feeds no longer configured (cascading their items). Fetch-state columns on existing feeds are preserved.
func (*FeedService) UpdateFeed ¶
func (s *FeedService) UpdateFeed(ctx context.Context, id int64, upd firehose.FeedUpdate) (*firehose.Feed, error)
UpdateFeed applies fetch/health state. Nil fields in upd are left unchanged.
type ItemService ¶
type ItemService struct {
// contains filtered or unexported fields
}
ItemService is the SQLite-backed firehose.ItemService.
func NewItemService ¶
func NewItemService(db *DB) *ItemService
NewItemService constructs an ItemService over db.
func (*ItemService) FindItems ¶
func (s *ItemService) FindItems(ctx context.Context, filter firehose.ItemFilter) ([]*firehose.Item, int, error)
FindItems returns items matching filter, newest-first (published desc, then id desc as a stable tiebreaker for deterministic output), and the total count before offset/limit.
Category selection joins feed.categories. Because categories are stored as a newline-joined TEXT column, category matching is done in Go after scanning; the display window is applied in SQL (it is the selective predicate).
func (*ItemService) PurgeExpired ¶
PurgeExpired deletes items published before olderThan (the cache-retention cutoff, distinct from and older than the display window). Returns the count removed.
func (*ItemService) UpsertItems ¶
UpsertItems inserts new items and updates changed ones, keyed by (feed_id, guid). Existing rows keep their kid.ID so IDs stay stable across runs (id.Time() and deterministic ordering both depend on this). Items with a zero ID are assigned a fresh kid.ID on insert.