Documentation ¶
Index ¶
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func MustAsset(name string) []byte
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- type DB
- func (db *DB) ActivateLoginToken(ctx context.Context, token string) (string, error)
- func (db *DB) AddFeed(ctx context.Context, sessionKey, folderID, title, plugin, feedURL string, ...) (string, error)
- func (db *DB) AddFolder(ctx context.Context, sessionKey, name string) (string, error)
- func (db *DB) CheckIfFeedExists(ctx context.Context, sessionKey, folderID, plugin, url string) (*hydrocarbon.Feed, bool, error)
- func (db *DB) Close() error
- func (db *DB) CreateLoginToken(ctx context.Context, userID, userAgent, ip string) (string, error)
- func (db *DB) CreateOrGetUser(ctx context.Context, email string) (string, bool, error)
- func (db *DB) CreateSession(ctx context.Context, userID, userAgent, ip string) (email string, key string, err error)
- func (db *DB) DeactivateSession(ctx context.Context, key string) error
- func (db *DB) EndScrape(ctx context.Context, id uuid.UUID, datums, retries, tasks int) error
- func (db *DB) ErrorScrape(ctx context.Context, id uuid.UUID, err error) error
- func (db *DB) FindMissingSchedules(ctx context.Context, limit int) ([]*discollect.ScheduleRequest, error)
- func (db *DB) GetFeedPosts(ctx context.Context, sessionKey, feedID string, limit, offset int) (*hydrocarbon.Feed, error)
- func (db *DB) GetFoldersWithFeeds(ctx context.Context, sessionKey string) ([]*hydrocarbon.Folder, error)
- func (db *DB) GetPost(ctx context.Context, sessionKey, postID string) (*hydrocarbon.Post, error)
- func (db *DB) InsertSchedule(ctx context.Context, sr *discollect.ScheduleRequest, ...) error
- func (db *DB) ListScrapes(ctx context.Context, stateFilter string, limit, offset int) ([]*discollect.Scrape, error)
- func (db *DB) ListSessions(ctx context.Context, key string, page int) ([]*hydrocarbon.Session, error)
- func (db *DB) MarkRead(ctx context.Context, sessionKey, postID string) error
- func (db *DB) RemoveFeed(ctx context.Context, sessionKey, folderID, feedID string) error
- func (db *DB) SetStripeIDs(ctx context.Context, userID, customerID, subID string) error
- func (db *DB) StartScrapes(ctx context.Context, limit int) (ss []*discollect.Scrape, err error)
- func (db *DB) VerifyKey(ctx context.Context, key string) error
- func (db *DB) Write(ctx context.Context, scrapeID uuid.UUID, f interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
A DB is responsible for all interactions with postgres
func (*DB) ActivateLoginToken ¶
ActivateLoginToken activates the given LoginToken and returns the user the token was for
func (*DB) AddFeed ¶
func (db *DB) AddFeed(ctx context.Context, sessionKey, folderID, title, plugin, feedURL string, initialConfig *discollect.Config) (string, error)
AddFeed adds the given URL to the users default folder and links it across feed_folder
func (*DB) CheckIfFeedExists ¶
func (db *DB) CheckIfFeedExists(ctx context.Context, sessionKey, folderID, plugin, url string) (*hydrocarbon.Feed, bool, error)
CheckIfFeedExists checks if a given feed exists in the DB already, and if it does, adds it to the folder specified
func (*DB) CreateLoginToken ¶
CreateLoginToken creates a new one-time-use login token
func (*DB) CreateOrGetUser ¶
CreateOrGetUser creates a new user and returns the users ID
func (*DB) CreateSession ¶
func (db *DB) CreateSession(ctx context.Context, userID, userAgent, ip string) (email string, key string, err error)
CreateSession creates a new session for the user ID and returns the session key
func (*DB) DeactivateSession ¶
DeactivateSession invalidates the current session
func (*DB) EndScrape ¶
EndScrape marks a scrape as SUCCESS and records the number of datums and tasks returned
func (*DB) ErrorScrape ¶
ErrorScrape marks a scrape as ERRORED and adds the error to its list
func (*DB) FindMissingSchedules ¶
func (db *DB) FindMissingSchedules(ctx context.Context, limit int) ([]*discollect.ScheduleRequest, error)
FindMissingSchedules pulls info to ask a plugin to create a schedule
func (*DB) GetFeedPosts ¶
func (db *DB) GetFeedPosts(ctx context.Context, sessionKey, feedID string, limit, offset int) (*hydrocarbon.Feed, error)
GetFeedPosts returns a single feed
func (*DB) GetFoldersWithFeeds ¶
func (db *DB) GetFoldersWithFeeds(ctx context.Context, sessionKey string) ([]*hydrocarbon.Folder, error)
GetFolders returns all of the folders for a user - if there are none it creates a default folder
func (*DB) InsertSchedule ¶
func (db *DB) InsertSchedule(ctx context.Context, sr *discollect.ScheduleRequest, ss []*discollect.ScrapeSchedule) error
InsertSchedule inserts all the schedules
func (*DB) ListScrapes ¶
func (db *DB) ListScrapes(ctx context.Context, stateFilter string, limit, offset int) ([]*discollect.Scrape, error)
ListScrapes is used to list and filter scrapes, for both session resumption and UI purposes
func (*DB) ListSessions ¶
func (db *DB) ListSessions(ctx context.Context, key string, page int) ([]*hydrocarbon.Session, error)
ListSessions lists all sessions a user has
func (*DB) RemoveFeed ¶
RemoveFeed removes the given feed ID from the user
func (*DB) SetStripeIDs ¶
SetStripeIDs sets a users stripe IDs
func (*DB) StartScrapes ¶
StartScrapes selects a subset of scrapes that should currently be running, but are not yet.