store

package
v0.0.0-...-5cb46ee Latest Latest
Warning

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

Go to latest
Published: May 18, 2019 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FeedId

type FeedId int64

FeedId is a unique identifier for each feed stored in the database

type FeedItemId

type FeedItemId int64

FeedItemId is a unique identifier for each feed item stored in the database

type FeedItemRecord

type FeedItemRecord struct {
	Id FeedItemId

	// Title of the item (retrieved)
	Title string

	// Date the item was published
	Date time.Time

	// Url of the item
	Url string

	// Globally unique identifier for the item, retrieved
	// from the feed source.
	Guid string
}

FeedItemRecord is the data associated with a feed item in the database

type FeedRecord

type FeedRecord struct {
	Id FeedId

	// Url for the feed, must be unique
	Url string

	// Name of the feed
	Name string
}

FeedRecord is the data associated with a feed in the database

type FeedStore

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

FeedStore provides thread-safe CRUD operations for feeds and feed items

func NewFeedStore

func NewFeedStore(dbPath string) *FeedStore

NewFeedStore configures a feed store instance. This does NOT open a database connection. See the SQLite driver documentation for the `dbPath` format

func (*FeedStore) Close

func (s *FeedStore) Close()

Close gracefully shuts down the database This must be called before the application exits

func (*FeedStore) DeleteFeed

func (s *FeedStore) DeleteFeed(feedId FeedId) error

DeleteFeed transactionally deletes the specified feed and all its items

func (*FeedStore) GetOrCreateFeedWithUrl

func (s *FeedStore) GetOrCreateFeedWithUrl(url string) (FeedId, error)

InsertFeedWithUrl creates a feed record for the specified URL This is a placeholder with no feed items, meant to be updated once the feed is loaded from an external source (e.g. RSS XML)

func (*FeedStore) Initialize

func (s *FeedStore) Initialize() error

Initialize opens the database and (if necessary) creates tables, indices, and prepared statements.

func (*FeedStore) RetrieveFeed

func (s *FeedStore) RetrieveFeed(id FeedId) (FeedRecord, error)

RetrieveFeed retrieves a single feed record by its id.

func (*FeedStore) RetrieveFeedItems

func (s *FeedStore) RetrieveFeedItems(feedId FeedId) ([]FeedItemRecord, error)

RetrieveFeedItems retrieves a record for every feed item for a given feed

func (*FeedStore) RetrieveFeedSyncStatus

func (s *FeedStore) RetrieveFeedSyncStatus(id FeedId) (bool, FeedSyncStatus, error)

RetrieveFeedSyncStatus retrieves the status of the most recently completed sync attempt If no attempt has yet completed because the feed was just added, then the first return value will be false.

func (*FeedStore) RetrieveFeeds

func (s *FeedStore) RetrieveFeeds() ([]FeedRecord, error)

RetrieveFeeds retrieves a record for every feed in the database

func (*FeedStore) SetFeedSyncStatusError

func (s *FeedStore) SetFeedSyncStatusError(id FeedId, syncErr error) error

SetFeedSyncStatusError sets the most recent sync attempt to "error" status

func (*FeedStore) SyncFeed

func (s *FeedStore) SyncFeed(id FeedId, feed feed.Feed) error

SyncFeed atomically updates a feed record and its items. The feed name (but not ID) is overwritten with the new name. The feed items are upserted, using the record GUID as the record's identity. Existing items NOT included in the new feed are retained (not deleted)

type FeedSyncStatus

type FeedSyncStatus struct {
	// The datetime of the last sync attempt
	Date time.Time

	// Whether the last sync attempt was successful
	Success bool

	// The error, if any, that occurred during the sync
	// This isn't displayed in the UI, but we store it anyway
	// for debugging purposes.
	Error error
}

FeedSyncStatus represents the most recent attempt to synchronize the feed with its external source.

Jump to

Keyboard shortcuts

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