Documentation
¶
Overview ¶
Package engine keeps the local cache in step with GitHub: it fetches changes, queues the user's edits in the outbox, and sends them.
Index ¶
- func SortIssues(issues []issue.Issue)
- type Draft
- type Engine
- func (e *Engine) Apply(i issue.Issue, ch issue.Change) ([]store.Op, error)
- func (e *Engine) Assign(i issue.Issue, add, remove []string) ([]store.Op, error)
- func (e *Engine) CachedComments(i issue.Issue) ([]store.Comment, bool)
- func (e *Engine) CachedMe() string
- func (e *Engine) Comment(i issue.Issue, body string) ([]store.Op, error)
- func (e *Engine) Comments(ctx context.Context, i issue.Issue) ([]store.Comment, error)
- func (e *Engine) Convention() issue.Convention
- func (e *Engine) Create(d Draft) ([]store.Op, error)
- func (e *Engine) Discard(op store.Op) error
- func (e *Engine) Edit(i issue.Issue, title, body string) ([]store.Op, error)
- func (e *Engine) Flush(ctx context.Context) (FlushResult, error)
- func (e *Engine) FlushOnly(ctx context.Context, ids ...string) (FlushResult, error)
- func (e *Engine) KeepMine(op store.Op) error
- func (e *Engine) Me(ctx context.Context) string
- func (e *Engine) Online() bool
- func (e *Engine) Refresh(ctx context.Context, repo string) (RefreshResult, error)
- func (e *Engine) RefreshAll(ctx context.Context, repos []string) ([]RefreshResult, error)
- func (e *Engine) Restore(opIDs []string, before, current issue.Issue) ([]store.Op, error)
- func (e *Engine) Retry(op store.Op) error
- func (e *Engine) SetStatus(i issue.Issue, s issue.Status) ([]store.Op, error)
- func (e *Engine) SetType(i issue.Issue, t issue.Type) ([]store.Op, error)
- func (e *Engine) Snapshot(repos []string) (Snapshot, error)
- func (e *Engine) Store() *store.Store
- func (e *Engine) Submit(op store.Op) (store.Op, error)
- func (e *Engine) TakeTheirs(op store.Op) error
- type FlushResult
- type RefreshResult
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SortIssues ¶
SortIssues orders issues by most recently updated first.
Types ¶
type Draft ¶
type Draft struct {
Repo string
Title string
Body string
Type issue.Type
Status issue.Status
Labels []string
Assignees []string
}
Draft describes a new issue.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine coordinates the GitHub client, the cache, and the outbox. Its methods are safe to call from multiple goroutines.
func (*Engine) CachedComments ¶
CachedComments returns cached comments without contacting GitHub, and whether they are current.
func (*Engine) Comments ¶
Comments returns an issue's comments, from the cache when the issue hasn't changed on GitHub since they were fetched.
func (*Engine) Convention ¶
func (e *Engine) Convention() issue.Convention
func (*Engine) Create ¶
Create queues a new issue. Statuses that need a closed issue are queued as a follow-up change.
func (*Engine) Flush ¶
func (e *Engine) Flush(ctx context.Context) (FlushResult, error)
Flush sends queued changes in order. Changes to an issue wait behind any earlier change to the same issue that couldn't be sent. Flushing stops at the first network failure; the rest is retried on the next flush.
func (*Engine) KeepMine ¶
KeepMine resolves a conflict by overwriting GitHub's version with the user's edit.
func (*Engine) Me ¶
Me returns the authenticated user's login, from GitHub when possible and from the cache otherwise.
func (*Engine) Online ¶
Online reports whether the engine has a GitHub client. Without one it can still read the cache and queue changes.
func (*Engine) RefreshAll ¶
RefreshAll refreshes repos concurrently and returns the first error.
func (*Engine) Restore ¶
Restore undoes earlier changes to an issue: changes still in the outbox are discarded, and anything already sent is reverted by queueing the opposite change. before is the issue as it was, current as it is now.
type FlushResult ¶
type FlushResult struct {
Sent int
Held int
Offline bool
// Created maps local IDs to the issue numbers GitHub assigned.
Created map[string]int
// Err is the most recent failure, for display.
Err error
}
FlushResult summarizes a flush.
type RefreshResult ¶
RefreshResult describes what a refresh found.
type Snapshot ¶
type Snapshot struct {
Issues []issue.Issue
// Pending maps issue keys to the changes still waiting to be sent.
Pending map[string][]store.Op
// Labels lists every known label per repo.
Labels map[string][]gh.Label
// FetchedAt is the time of each repo's last successful refresh.
FetchedAt map[string]time.Time
}
Snapshot is the issues triage should display: the cache with every pending change applied on top.
func (Snapshot) LastFetched ¶
LastFetched returns the oldest refresh time across repos, or zero if a repo has never been fetched.
func (Snapshot) PendingCount ¶
PendingCount returns how many ops are queued, and how many of those need the user's attention.