Documentation
¶
Index ¶
- type Abonnement
- type AbonnementStorage
- type Abonnements
- func (db *Abonnements) Create(chatId int64, chatTitle string, feedUrl string, ...) error
- func (db *Abonnements) Delete(chatId int64, feedId int64) error
- func (db *Abonnements) DisableFeed(feedID int64, reason string) error
- func (db *Abonnements) ExistsByFeedUrl(chatId int64, feedUrl string) (bool, error)
- func (db *Abonnements) ExistsById(chatId int64, feedId int64) (bool, error)
- func (db *Abonnements) GetAll() ([]Abonnement, error)
- func (db *Abonnements) GetByUser(chatId int64) ([]Feed, error)
- func (db *Abonnements) GetDue() ([]Abonnement, error)
- func (db *Abonnements) MoveFeedURL(feedID int64, newURL string) (bool, error)
- func (db *Abonnements) ReactivateFeed(feedUrl string, nextPollAt time.Time) (bool, error)
- func (db *Abonnements) Reschedule(feedID int64, nextPollAt time.Time, errorCount, unchangedCount int) error
- func (db *Abonnements) SetFeedState(feedID int64, lastEntry, etag, lastModified *string, hints PollHints, ...) error
- type Chat
- type DB
- type Feed
- type PollHints
- type Replacement
- type Replacements
- type ReplacementsStorage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Abonnement ¶
type AbonnementStorage ¶
type AbonnementStorage interface {
Create(chatId int64, chatTitle string, feedUrl string, lastEntry, etag, lastModified *string, hints PollHints, nextPollAt time.Time) error
Delete(chatId int64, feedId int64) error
ExistsByFeedUrl(chatId int64, feedUrl string) (bool, error)
ExistsById(chatId int64, feedId int64) (bool, error)
GetByUser(chatId int64) ([]Feed, error)
GetAll() ([]Abonnement, error)
GetDue() ([]Abonnement, error)
SetFeedState(feedID int64, lastEntry, etag, lastModified *string, hints PollHints, nextPollAt time.Time, errorCount, unchangedCount int) error
Reschedule(feedID int64, nextPollAt time.Time, errorCount, unchangedCount int) error
MoveFeedURL(feedID int64, newURL string) (bool, error)
DisableFeed(feedID int64, reason string) error
ReactivateFeed(feedUrl string, nextPollAt time.Time) (bool, error)
}
type Abonnements ¶
func (*Abonnements) DisableFeed ¶
func (db *Abonnements) DisableFeed(feedID int64, reason string) error
DisableFeed retires a feed that has gone away (FRB110-118).
func (*Abonnements) ExistsByFeedUrl ¶
func (db *Abonnements) ExistsByFeedUrl(chatId int64, feedUrl string) (bool, error)
func (*Abonnements) ExistsById ¶
func (db *Abonnements) ExistsById(chatId int64, feedId int64) (bool, error)
func (*Abonnements) GetAll ¶
func (db *Abonnements) GetAll() ([]Abonnement, error)
func (*Abonnements) GetDue ¶
func (db *Abonnements) GetDue() ([]Abonnement, error)
GetDue returns only feeds that are enabled and whose scheduled poll time has passed (or was never set). This is what keeps polling on a per-feed schedule and prevents a process restart from re-downloading everything (FRB037). Timestamps are always passed from Go instead of using NOW(), so they are written and compared in the driver's loc regardless of the MySQL time zone.
func (*Abonnements) MoveFeedURL ¶
func (db *Abonnements) MoveFeedURL(feedID int64, newURL string) (bool, error)
MoveFeedURL persists a permanent redirect target (FRB130/131). If another feed already occupies newURL (feeds.url is UNIQUE), this feed's subscriptions are merged onto that existing feed instead and the old feed row is removed; the returned bool reports whether such a merge happened.
func (*Abonnements) ReactivateFeed ¶
ReactivateFeed re-enables a retired feed, e.g. after it was successfully fetched again on subscribe. It reports whether the feed was disabled.
func (*Abonnements) Reschedule ¶
func (db *Abonnements) Reschedule(feedID int64, nextPollAt time.Time, errorCount, unchangedCount int) error
Reschedule updates only the poll schedule and counters, preserving the cached etag/last_modified (FRB010-016) — used for 304, rate-limiting and transient errors. failing_since marks the start of an error streak and is cleared once errorCount drops back to 0.
func (*Abonnements) SetFeedState ¶
func (db *Abonnements) SetFeedState(feedID int64, lastEntry, etag, lastModified *string, hints PollHints, nextPollAt time.Time, errorCount, unchangedCount int) error
SetFeedState writes the atomic cache set (etag + last_modified), the last seen entry, the feed's polling hints and the next poll schedule after a successful 200 response.
type DB ¶
type DB struct {
*sqlx.DB
Abonnements AbonnementStorage
Replacements ReplacementsStorage
}
type Feed ¶
type Feed struct {
ID int64 `db:"id"`
Url string `db:"url"`
LastEntry sql.NullString `db:"last_entry"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt sql.NullTime `db:"updated_at"`
ETag sql.NullString `db:"etag"`
LastModified sql.NullString `db:"last_modified"`
NextPollAt sql.NullTime `db:"next_poll_at"`
LastPollAt sql.NullTime `db:"last_poll_at"`
ErrorCount int `db:"error_count"`
UnchangedCount int `db:"unchanged_count"`
Disabled bool `db:"disabled"`
DisabledReason sql.NullString `db:"disabled_reason"`
FeedInterval int `db:"feed_interval"`
SkipHours sql.NullString `db:"skip_hours"`
SkipDays sql.NullString `db:"skip_days"`
FailingSince sql.NullTime `db:"failing_since"`
}
type PollHints ¶
PollHints are the polling hints a feed declares in its body (ttl, skipHours, skipDays). They are persisted so they still apply after a 304.
type Replacement ¶
type Replacements ¶
func (*Replacements) Delete ¶
func (db *Replacements) Delete(replacementId int64) error
func (*Replacements) List ¶
func (db *Replacements) List() ([]Replacement, error)