Documentation
¶
Overview ¶
Package gtd is the GTD service: entries derived from items, captured by the user or opened by other services, and the verbs that move them.
Index ¶
- Variables
- func Accepts(e gtd.Entry, verb gtd.Verb) error
- func Delta(all []gtd.Entry, q gtd.Query, changed func(gtd.ID) bool) (in []gtd.Entry, removed []gtd.ID)
- type CardFacts
- type Deps
- type Facts
- type Items
- type OpenRequest
- type Page
- type ProjectDeps
- type ProjectDossiers
- type ProjectState
- type ProjectStore
- type Reader
- type Request
- type Result
- type Review
- type ReviewStep
- type Service
- func (s *Service) Capture(ctx context.Context, title, notes string, u *unit.Unit) (gtd.Entry, error)
- func (s *Service) Close(ctx context.Context, id gtd.ID, to gtd.State) error
- func (s *Service) Counts(ctx context.Context, area string) (gtd.Counters, error)
- func (s *Service) CountsWhere(ctx context.Context, area string, keep func(gtd.Entry) (bool, error)) (gtd.Counters, error)
- func (s *Service) Do(ctx context.Context, id gtd.ID, req Request) (Result, error)
- func (s *Service) Entries(ctx context.Context, q gtd.Query) ([]gtd.Entry, error)
- func (s *Service) EntriesSince(ctx context.Context, q gtd.Query, since Since) (Page, error)
- func (s *Service) Entry(ctx context.Context, id gtd.ID) (gtd.Entry, error)
- func (s *Service) Handles(kind gtd.Kind, verb gtd.Verb) bool
- func (s *Service) Nudged(ctx context.Context, ids []gtd.ID, u unit.Unit, at time.Time) error
- func (s *Service) Open(ctx context.Context, r OpenRequest) (gtd.Entry, error)
- func (s *Service) ProjectsStatus(ctx context.Context) (map[gtd.ID]ProjectState, error)
- func (s *Service) Register(kind gtd.Kind, verb gtd.Verb, h VerbHandler)
- func (s *Service) RegisterView(v gtd.View, prefix string, src ViewSource)
- func (s *Service) Retitle(ctx context.Context, id gtd.ID, title string) error
- func (s *Service) Review(ctx context.Context) (Review, error)
- func (s *Service) ReviewStepDone(ctx context.Context, step string) (Review, error)
- func (s *Service) ServeProjects(d ProjectDeps)
- func (s *Service) Serves(v gtd.View) bool
- func (s *Service) SetMe(me gtd.Me)
- func (s *Service) Sync(ctx context.Context, units []unit.Unit) error
- type Since
- type Store
- type VerbHandler
- type ViewSource
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoEntry = errors.New("no such entry") ErrVerb = errors.New("the entry's state refuses the verb") // ErrArgs is a request the service cannot read: an unknown verb or view, or a missing or bad argument. ErrArgs = errors.New("bad entry request") // ErrPluginDisabled refuses a change to an entry whose unit's plugin is disabled. ErrPluginDisabled = errors.New("the unit's plugin is disabled") )
Functions ¶
func Accepts ¶
Accepts says whether e's state takes verb with no handler: ErrArgs for an unknown verb, ErrVerb naming the verb and the state for a refused one. approve, delegate, answer, edit and retry move nothing on their own, so it refuses them.
func Delta ¶
func Delta(all []gtd.Entry, q gtd.Query, changed func(gtd.ID) bool) (in []gtd.Entry, removed []gtd.ID)
Delta is the incremental page of q over all, the entries a store holds for q and every entry changed after the client's position (changed says which): the changed entries in q's view, and the changed ids out of it. A change to a project, or to one of its actions, counts as a change to all its actions, since the sequential rule may move another one into Next. Removed may name ids the client never held.
Types ¶
type CardFacts ¶
type CardFacts struct {
Cards card.Store
// Enabled says whether a provider's plugin is enabled; nil: every one is.
Enabled func(unit.ProviderID) bool
// Me is the user's identity now; nil: nobody.
Me func() gtd.Me
}
CardFacts reads a unit's facts from its stored card (#unit-card).
type Deps ¶
type Deps struct {
Store Store
Items Items
Facts Facts
Me gtd.Me
Clock port.Clock
// StaleWaitingDays is how many working days a waiting entry waits before AutoFocus stars it.
StaleWaitingDays int
// Disabled are the providers whose plugin is disabled now; nil: none is.
Disabled func() []unit.ProviderID
}
Deps is what the service runs on.
type OpenRequest ¶
type ProjectDeps ¶
type ProjectDeps struct {
Store ProjectStore
Dossiers ProjectDossiers // nil keeps no dossiers
}
type ProjectDossiers ¶
type ProjectDossiers interface {
Open(ctx context.Context, slug string) error
Resolved(ctx context.Context, slug string, at time.Time) error
}
ProjectDossiers opens a new project's dossier and starts its lifecycle once the project ends (#dossier).
type ProjectState ¶
type ProjectState struct {
gtd.ProjectStatus
Due bool // past its review interval
}
ProjectState is a project's status at the service's now.
type ProjectStore ¶
type ProjectStore interface {
// SlugTaken says whether a project, done or not, holds slug.
SlugTaken(ctx context.Context, slug string) (bool, error)
// CurrentRun is the Review run with a step still open.
CurrentRun(ctx context.Context) (gtd.ReviewRun, bool, error)
PutRun(ctx context.Context, r gtd.ReviewRun) error
}
ProjectStore keeps what the projects need beyond their entries: the slugs taken and the Review's runs.
type Reader ¶
type Reader interface {
Entries(ctx context.Context, q gtd.Query) ([]gtd.Entry, error)
// EntriesSince is the page of q after position since: Full when since is from another epoch or too old;
// else the entries of q changed after Rev and the ids that left q. Counts in the same read transaction.
EntriesSince(ctx context.Context, q gtd.Query, since Since) (Page, error)
Entry(ctx context.Context, id gtd.ID) (gtd.Entry, error) // ErrNoEntry; ErrVerb is a verb the entry's state refuses, naming both
EntriesOf(ctx context.Context, u unit.Unit) ([]gtd.Entry, error)
Counts(ctx context.Context, area string) (gtd.Counters, error) // stored views only
}
Reader is the read half of Store.
type Review ¶
type Review struct {
ID string
StartedAt time.Time
Steps []ReviewStep
Done bool
}
Review is the weekly Review as it stands: its steps in order, each with its count. ID is empty while nothing was left to review when it started, so nothing was recorded.
type ReviewStep ¶
type ReviewStep struct {
gtd.ReviewStep
Count int
Done bool
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) Capture ¶
func (s *Service) Capture(ctx context.Context, title, notes string, u *unit.Unit) (gtd.Entry, error)
Capture files a new entry in the Inbox.
func (*Service) Close ¶
Close moves an entry opened by Open or Capture to Done or Trash; a derived entry, or one whose unit's plugin is disabled, refuses it.
func (*Service) Counts ¶
Counts is Store.Counts plus each ViewSource.Count but review's; Badge is Inbox plus Outbox.
func (*Service) CountsWhere ¶ added in v0.2.0
func (s *Service) CountsWhere(ctx context.Context, area string, keep func(gtd.Entry) (bool, error)) (gtd.Counters, error)
CountsWhere is Counts over the entries keep holds: each view, area and context counts only the entries of its list that keep takes, so a client's filter narrows the counters as it narrows the lists.
func (*Service) Do ¶
Do runs req.Verb on entry id: a registered handler first, else the state change. An entry of a unit whose plugin is disabled refuses every verb with ErrPluginDisabled but dismiss, which moves a derived entry, or one whose units are all of disabled plugins, to the Trash whole, and detaches a disabled plugin's units from any other.
func (*Service) Entries ¶
Entries is q's view, from its registered ViewSource or the store; the outbox is empty while none serves it. A disabled plugin's entries are left out, as hidden says.
func (*Service) EntriesSince ¶
EntriesSince is q's page after since with the counters of q's area: a registered ViewSource's view is always Full, at the store's position.
func (*Service) Nudged ¶
Nudged records a nudge sent at at on the live waiting entries ids names, or, with no ids, on every live waiting entry of u. It reads them under the service's lock, so it never writes back a copy older than a concurrent Sync's, and it never moves LastNudge back.
func (*Service) Open ¶
Open creates an entry another service owns the content of (messages): Kind, Inbox, random id.
func (*Service) ProjectsStatus ¶
ProjectsStatus is each live project's next action, open actions and review mark, over one read of the open set.
func (*Service) RegisterView ¶
func (s *Service) RegisterView(v gtd.View, prefix string, src ViewSource)
RegisterView serves v from src; ids starting with prefix are read from it.
func (*Service) Retitle ¶
Retitle renames an entry opened by Open or Capture, as one change; a derived entry refuses it.
func (*Service) Review ¶
Review is the current Review, or a new one: a step whose count is 0 at its start starts done, and a new Review is recorded once a step is left to do.
func (*Service) ReviewStepDone ¶
ReviewStepDone marks step done in the current Review, recording the Review once every step is.
func (*Service) ServeProjects ¶
func (s *Service) ServeProjects(d ProjectDeps)
ServeProjects runs the project verbs on s (project with its position, sequential, reviewed), resolves an ending project's dossier, and serves the review view and the Review.
func (*Service) Serves ¶
Serves says whether v is served: a stored view, the outbox, or a view a ViewSource serves.
func (*Service) Sync ¶
Sync reconciles the units named by a TopicItems, TopicSourceEvents or TopicCards note, then AutoFocus and Wake for all, in one Apply. A unit whose plugin is disabled keeps its entries as they are. A snooze that ends reconciles its entry's units after waking it, so a still-muted unit snoozes it again before anything sees it in the Inbox.
type VerbHandler ¶
VerbHandler runs a verb another service owns (answer/approve/dismiss on messages, approve/dismiss on drafts).
type ViewSource ¶
type ViewSource interface {
Entries(ctx context.Context, q gtd.Query) ([]gtd.Entry, error)
Entry(ctx context.Context, id gtd.ID) (gtd.Entry, bool, error)
Count(ctx context.Context, area string) (int, error)
}
ViewSource serves a view whose entries live elsewhere (outbox with prefix "draft:", review). Its ids carry its prefix; Count is what the view's counter shows.