Documentation
¶
Overview ¶
Package activity records what maild does in the background as typed entries that hold no text (ADR-0055), keeps the newest in memory, and delivers them to the connections that subscribed.
Only this package makes an api.ActivityEntry: the sync, send, PIM and OAuth code records an Entry made by one of the constructors in entries.go, and Classify reduces an error to its class and code without reading its text. A test of the module's source holds that rule.
Index ¶
- Constants
- func Classify(err error) (api.ErrorClass, *int64, *api.ImapCode)
- func Line(e api.ActivityEntry, names Names) (source, text string)
- type Entry
- func Announced(account int64, n int) Entry
- func Connected(account int64, d time.Duration) Entry
- func DraftSaved(account int64, n int) Entry
- func Erased(account, mailbox int64, n int) Entry
- func Failed(account int64, s api.ActivityServer, err error) Entry
- func Fetched(account int64, n int, bytes int64, d time.Duration) Entry
- func IdleWoke(account, mailbox int64) Entry
- func Listed(account int64, n int, d time.Duration) Entry
- func Lost(account int64, s api.ActivityServer, err error) Entry
- func MailboxSynced(account, mailbox int64, added, changed, removed int, d time.Duration) Entry
- func Offline(account int64, s api.ActivityServer, err error) Entry
- func PIMRefused(account int64, s api.ActivityServer, err error) Entry
- func PIMSynced(account int64, s api.ActivityServer, changed int, d time.Duration) Entry
- func Pushed(account int64, n int) Entry
- func Refreshed(account int64, err error) Entry
- func RemindFired(account int64, n int) Entry
- func RulesApplied(account int64, n int) Entry
- func SendFailed(account int64, err error, retried bool) Entry
- func SendLater(account int64, n int) Entry
- func Sent(account int64, d time.Duration) Entry
- func SignInNeeded(account int64, s api.ActivityServer, err error) Entry
- func TokenRefreshed(account int64) Entry
- type Hub
- type Names
- type Sub
Constants ¶
const ( // Keep is how many entries a Hub holds. Keep = 2000 // SubscriberBuffer is how many entries a subscription holds before it // loses entries. SubscriberBuffer = 256 // PerSecond is how many debug and info entries of one kind an account // may record in one second; the rest are counted in a dropped entry. // Warnings and errors are always kept. PerSecond = 20 // MaxRecent and DefaultRecent bound activity.recent. MaxRecent = wireentry.MaxRecent DefaultRecent = 200 )
The bounds of ADR-0055.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry is an entry before a Hub numbers and times it. Only this package's constructors make one.
func DraftSaved ¶
DraftSaved: saved n drafts' copies on the server.
func Failed ¶
func Failed(account int64, s api.ActivityServer, err error) Entry
Failed: other work with s failed (err); retried with backoff.
func Lost ¶
func Lost(account int64, s api.ActivityServer, err error) Entry
Lost is Offline when err says s could not be reached, and Failed otherwise: the sync loop's one entry for a session that ended.
func MailboxSynced ¶
MailboxSynced: reconciled a mailbox, with the messages it added, whose flags changed and that it removed. A pass that changed nothing is debug.
func Offline ¶
func Offline(account int64, s api.ActivityServer, err error) Entry
Offline: s could not be reached (err); retried with backoff.
func PIMRefused ¶
func PIMRefused(account int64, s api.ActivityServer, err error) Entry
PIMRefused: s refused a contact, event or task change with err.
func PIMSynced ¶
PIMSynced: a contacts, calendar or tasks pass over s changed that many items, after d. A pass that changed nothing is debug.
func Refreshed ¶
Refreshed is the end of an OAuth token refresh: TokenRefreshed, or SignInNeeded when the provider refused the grant, or Failed.
func RemindFired ¶
RemindFired: Remind Me brought n messages back.
func RulesApplied ¶
RulesApplied: rules acted on n new messages.
func SendFailed ¶
SendFailed: a send failed with err. A failure that will be retried is a warning, one the server refused for good an error.
func SignInNeeded ¶
func SignInNeeded(account int64, s api.ActivityServer, err error) Entry
SignInNeeded: s refused the account's credentials with err. The class is auth unless err says better: a missing password or a refusal known only by a sentinel error is a refused sign-in too.
func TokenRefreshed ¶
TokenRefreshed: refreshed the account's OAuth access token.
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub keeps the newest entries and delivers each to the subscriptions. A nil Hub records nothing, so code that records needs no check.
func (*Hub) Recent ¶
func (h *Hub) Recent(limit int) []api.ActivityEntry
Recent returns the newest limit entries, oldest first; limit is clamped to 1..MaxRecent, and 0 means DefaultRecent.
func (*Hub) Record ¶
Record numbers and times e, keeps it, and delivers it. A debug or info entry of a kind an account has recorded PerSecond times in this second is lost; the account's next entry of that kind after that second is preceded by one dropped entry that counts what it lost. Warnings and errors are never lost here.
type Sub ¶
type Sub struct {
// contains filtered or unexported fields
}
Sub is one subscription. Its channel closes when it is closed.
func (*Sub) C ¶
func (s *Sub) C() <-chan api.ActivityEntry
C is the subscription's entries. A subscription that fell behind gets one dropped entry with seq 0 that counts the entries it lost, before the next entry it can take.