Documentation ¶
Index ¶
- func SchemaMigrations() []*gomigrate.Migration
- func TestFixtures() []*gomigrate.Migration
- type FeedInfo
- type FeedItem
- type Handle
- func (d *Handle) AddFeed(name string, feedURL string) (*FeedInfo, error)
- func (d *Handle) AddFeedsToUser(u *User, feeds []*FeedInfo) error
- func (d *Handle) AddUser(name string, email string, pass string) (*User, error)
- func (d *Handle) GetAllFeeds() ([]*FeedInfo, error)
- func (d *Handle) GetAllFeedsWithUsers() ([]*FeedInfo, error)
- func (d *Handle) GetAllUsers() ([]User, error)
- func (d *Handle) GetFeedByID(id int64) (*FeedInfo, error)
- func (d *Handle) GetFeedByURL(url string) (*FeedInfo, error)
- func (d *Handle) GetFeedItemByGUID(feedID int64, guid string) (*FeedItem, error)
- func (d *Handle) GetFeedUsers(feedURL string) ([]User, error)
- func (d *Handle) GetFeedsByName(name string) ([]*FeedInfo, error)
- func (d *Handle) GetFeedsWithErrors() ([]*FeedInfo, error)
- func (d *Handle) GetMostRecentGUIDsForFeed(feedID int64, max int) ([]string, error)
- func (d *Handle) GetStaleFeeds() ([]*FeedInfo, error)
- func (d *Handle) GetUser(name string) (*User, error)
- func (d *Handle) GetUserByEmail(email string) (*User, error)
- func (d *Handle) GetUserByID(id int64) (*User, error)
- func (d *Handle) GetUserFeedsWithErrors(user *User) ([]*FeedInfo, error)
- func (d *Handle) GetUserReport(u *User) (*UserReport, error)
- func (d *Handle) GetUserStaleFeeds(user *User) ([]*FeedInfo, error)
- func (d *Handle) GetUsersFeeds(u *User) ([]*FeedInfo, error)
- func (d *Handle) GetUsersFeedsByName(user *User, name string) ([]*FeedInfo, error)
- func (d *Handle) Migrate(m []*gomigrate.Migration) error
- func (d *Handle) RecordGUID(feedID int64, guid string) error
- func (d *Handle) RemoveFeed(url string) error
- func (d *Handle) RemoveFeedsFromUser(u *User, feeds []*FeedInfo) error
- func (d *Handle) RemoveUser(user *User) error
- func (d *Handle) RemoveUserByEmail(email string) error
- func (d *Handle) SaveFeed(f *FeedInfo) error
- func (d *Handle) SaveFeedItem(f *FeedItem) error
- func (d *Handle) SaveUser(u *User) error
- func (d *Handle) SetUserReport(u *User) error
- func (d *Handle) UpdateUsersFeeds(u *User, feedIDs []int64) error
- type Service
- type User
- type UserReport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SchemaMigrations ¶
SchemaMigrations gives each caller a new copy of the migrations. This is mostly useful to allow unit tests to run in parallel.
func TestFixtures ¶
TestFixtures gives the standard fixtures for db testing
Types ¶
type FeedInfo ¶
type FeedInfo struct { ID int64 `jsonapi:"primary,feeds"` Name string `jsonapi:"attr,name"` URL string `jsonapi:"attr,url"` SiteURL string `db:"site_url" jsonapi:"attr,site-url"` LastPollTime time.Time `db:"last_poll_time" jsonapi:"attr,last-poll-time,iso8601"` LastPollError string `db:"last_poll_error" jsonapi:"attr,last-poll-error"` LastErrorResponse string `db:"last_error_response"` Users []User `` }
FeedInfo represents a feed (atom, rss or rdf) that rss2go is polling.
type FeedItem ¶
type FeedItem struct { ID int64 FeedInfoID int64 `db:"feed_info_id"` GUID string AddedOn time.Time `db:"added_on"` }
FeedItem represents an individual iteam from a feed. It only captures the Guid for that item and is mainly used to check if a particular item has been seen before.
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
Handle controls access to the database and makes sure only one operation is in process at a time.
func NewDBHandle ¶
func NewDBHandle(dbPath string, logger logrus.FieldLogger) *Handle
NewDBHandle creates a new DBHandle
dbPath: the path to the database to use. verbose: when true database accesses are logged to stdout
func NewMemoryDBHandle ¶
func NewMemoryDBHandle(logger logrus.FieldLogger, loadFixtures bool) *Handle
NewMemoryDBHandle creates a new in memory database. Only used for testing. The name of the database is a random string so multiple tests can run in parallel with their own database.
func (*Handle) AddFeedsToUser ¶
AddFeedsToUser creates a UserFeed entry between the given user and feeds. This 'subscribes' the user to those feeds to they will get email updates for that feed.
func (*Handle) GetAllFeeds ¶
GetAllFeeds returns all feeds from the database.
func (*Handle) GetAllFeedsWithUsers ¶
GetAllFeedsWithUsers returns all feeds from the database that have subscribers
func (*Handle) GetAllUsers ¶
GetAllUsers returns all Users from the database.
func (*Handle) GetFeedByID ¶
GetFeedByID returns the FeedInfo for the given id.
func (*Handle) GetFeedByURL ¶
GetFeedByURL returns the FeedInfo for the given URL.
func (*Handle) GetFeedItemByGUID ¶
GetFeedItemByGUID returns a FeedItem for the given FeedInfo.Id and guid.
func (*Handle) GetFeedUsers ¶
GetFeedUsers returns all the users subscribed to a given feedURL
func (*Handle) GetFeedsByName ¶
GetFeedsByName returns all feeds that contain the given string in their name.
func (*Handle) GetFeedsWithErrors ¶
GetFeedsWithErrors returns all feeds that had an error on their last check.
func (*Handle) GetMostRecentGUIDsForFeed ¶
GetMostRecentGUIDsForFeed retrieves the most recent GUIDs for a given feed up to max. GUIDs are returned ordered with the most recent first.
func (*Handle) GetStaleFeeds ¶
GetStaleFeeds returns all feeds that haven't gotten new content in more than 14 days.
func (*Handle) GetUserByEmail ¶
GetUserByEmail returns the user with the given email from the database.
func (*Handle) GetUserByID ¶
GetUserByID returns the user with the given id from the database.
func (*Handle) GetUserFeedsWithErrors ¶
GetUserFeedsWithErrors returns all feeds that had an error on their last check that a given user is subscribed to.
func (*Handle) GetUserReport ¶
func (d *Handle) GetUserReport(u *User) (*UserReport, error)
func (*Handle) GetUserStaleFeeds ¶
GetUserStaleFeeds returns all feeds that haven't gotten new content in more than 14 days.
func (*Handle) GetUsersFeeds ¶
GetUsersFeeds returns all the FeedInfos that a user is subscribed to.
func (*Handle) GetUsersFeedsByName ¶
GetUsersFeedsByName returns all feeds that contain the given string in their name.
func (*Handle) RecordGUID ¶
RecordGUID adds a FeedItem record for the given feedID and guid.
func (*Handle) RemoveFeed ¶
RemoveFeed removes a FeedInfo from the database given it's URL
func (*Handle) RemoveFeedsFromUser ¶
RemoveFeedsFromUser does the opposite of AddFeedsToUser
func (*Handle) RemoveUser ¶
RemoveUser removes the given user from the database.
func (*Handle) RemoveUserByEmail ¶
RemoveUserByEmail removes the user with the given email from the database.
func (*Handle) SaveFeedItem ¶
SaveFeedItem updates the information for a given FeedItem
func (*Handle) SetUserReport ¶
type Service ¶
type Service interface { GetFeedByURL(string) (*FeedInfo, error) GetFeedUsers(string) ([]User, error) SaveFeed(*FeedInfo) error GetMostRecentGUIDsForFeed(int64, int) ([]string, error) RecordGUID(int64, string) error GetFeedItemByGUID(int64, string) (*FeedItem, error) }
Service defines the interface that the RSS2Go database provides. Useful for mocking out the databse layer in tests.
type User ¶
type User struct { ID int64 `jsonapi:"primary,feeds"` Name string `jsonapi:"attr,name"` Email string `jsonapi:"attr,email"` Enabled bool `` Password string `` Feeds []FeedInfo `jsonapi:"relation,feeds"` }
User represents a user/email address that can subscribe to Feeds
func (*User) SetPassword ¶
SetPassword takes a plain text password, crypts it and sets the Password field to that.