reminders

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 8 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 reminders fires calendar reminders when their alarms come due (docs/design/pim.md, Reminders): it records them as fired, tells the app, and, while the app is away, shows desktop notifications. Each minute it also has maild fire the messages' Remind Me reminders (ADR-0025), and once an hour erase the mail the user lets it erase from Trash and Junk (ADR-0051).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DB *store.DB
	// List is calendar.reminders: the reminders to show now.
	List func(ctx context.Context) ([]api.Reminder, error)
	// Attended reports whether the app is connected (rpcserver).
	Attended func() bool
	// Notifier shows reminders while the app is away; nil shows none.
	Notifier Notifier
	// Messages fires the Remind Me reminders of messages due by now
	// (mailsync.Manager.FireReminders); nil fires none.
	Messages func(ctx context.Context, now time.Time) error
	// Erase erases the old mail of every account whose Trash and Junk
	// settings let it (mailsync.Manager.EraseOld). It runs at the first
	// check and then once an hour; nil erases none.
	Erase func(ctx context.Context, now time.Time) error
	Now   func() time.Time
	Local *time.Location
	Log   *slog.Logger
}

Config is what the scheduler needs; nil Now, Local and Log take time.Now, time.Local and a discarding logger.

type Notifier

type Notifier interface {
	Remind(ctx context.Context, rs []notify.Reminder) error
	// Withdraw closes the notes of reminders not in active.
	Withdraw(ctx context.Context, active map[string]bool) error
}

Notifier shows reminders on the desktop (notify.Desktop).

type Scheduler

type Scheduler struct {
	// contains filtered or unexported fields
}

Scheduler checks for due reminders once a minute.

func New

func New(cfg Config) *Scheduler

New returns a Scheduler.

func (*Scheduler) Check

func (s *Scheduler) Check(ctx context.Context) error

Check fires the alarms due since the last check, and the snoozes that ended, and announces them: an event for the app, or notifications while it is away. It also withdraws the notes of reminders no longer shown, and erases the old Trash and Junk mail of the accounts that ask for it. Run calls it; tests call it with their clock.

func (*Scheduler) Kick

func (s *Scheduler) Kick()

Kick asks for a check now: a reminder was snoozed or dismissed, or the app came or went.

func (*Scheduler) Run

func (s *Scheduler) Run(ctx context.Context)

Run checks at each minute, and when kicked, until ctx ends.

Jump to

Keyboard shortcuts

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