activity

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func Classify

func Classify(err error) (api.ErrorClass, *int64, *api.ImapCode)

Classify reduces err to its class, an SMTP reply code or HTTP status, and an IMAP response code, from its type alone: it never reads the error's text, which can hold whatever a server said.

func Line

func Line(e api.ActivityEntry, names Names) (source, text string)

Line formats a wire entry for the client's console.

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 Announced

func Announced(account int64, n int) Entry

Announced: announced n new messages.

func Connected

func Connected(account int64, d time.Duration) Entry

Connected: logged in to the account's IMAP server, after d.

func DraftSaved

func DraftSaved(account int64, n int) Entry

DraftSaved: saved n drafts' copies on the server.

func Erased

func Erased(account, mailbox int64, n int) Entry

Erased: erased n old messages from a Trash or Junk mailbox.

func Failed

func Failed(account int64, s api.ActivityServer, err error) Entry

Failed: other work with s failed (err); retried with backoff.

func Fetched

func Fetched(account int64, n int, bytes int64, d time.Duration) Entry

Fetched: fetched n message bodies of bytes in all, after d.

func IdleWoke

func IdleWoke(account, mailbox int64) Entry

IdleWoke: IDLE reported news for a mailbox.

func Listed

func Listed(account int64, n int, d time.Duration) Entry

Listed: listed the account's n mailboxes, after d.

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

func MailboxSynced(account, mailbox int64, added, changed, removed int, d time.Duration) Entry

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

func PIMSynced(account int64, s api.ActivityServer, changed int, d time.Duration) Entry

PIMSynced: a contacts, calendar or tasks pass over s changed that many items, after d. A pass that changed nothing is debug.

func Pushed

func Pushed(account int64, n int) Entry

Pushed: replayed n offline changes to the server.

func Refreshed

func Refreshed(account int64, err error) Entry

Refreshed is the end of an OAuth token refresh: TokenRefreshed, or SignInNeeded when the provider refused the grant, or Failed.

func RemindFired

func RemindFired(account int64, n int) Entry

RemindFired: Remind Me brought n messages back.

func RulesApplied

func RulesApplied(account int64, n int) Entry

RulesApplied: rules acted on n new messages.

func SendFailed

func SendFailed(account int64, err error, retried bool) Entry

SendFailed: a send failed with err. A failure that will be retried is a warning, one the server refused for good an error.

func SendLater

func SendLater(account int64, n int) Entry

SendLater: queued n messages to send later.

func Sent

func Sent(account int64, d time.Duration) Entry

Sent: the SMTP server accepted a message, after d.

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

func TokenRefreshed(account int64) Entry

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 New

func New(now func() time.Time) *Hub

New returns a Hub that times entries with now (time.Now when nil).

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

func (h *Hub) Record(e Entry)

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.

func (*Hub) Subscribe

func (h *Hub) Subscribe() (*Sub, int64)

Subscribe starts a subscription that gets every entry recorded from now on, and returns the newest entry's seq (0 when there is none).

type Names

type Names = wire.Names

Names gives a client's display names to the activity formatter.

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.

func (*Sub) Close

func (s *Sub) Close()

Close ends the subscription; closing twice does nothing.

Directories

Path Synopsis
Package entry contains wire-level activity helpers shared by maild and its clients.
Package entry contains wire-level activity helpers shared by maild and its clients.

Jump to

Keyboard shortcuts

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