Documentation
¶
Overview ¶
Package store persists cached GitHub data and the outbox of changes that haven't reached GitHub yet.
Index ¶
- func NewID() string
- type Comment
- type CommentCache
- type Conflict
- type Meta
- type Op
- type OpKind
- type RepoCache
- type Store
- func (s *Store) Claim(id string) (bool, error)
- func (s *Store) ClaimOp(id string) (Op, bool, error)
- func (s *Store) Complete(id string) error
- func (s *Store) Discard(id string) (bool, error)
- func (s *Store) Enqueue(op Op) (Op, error)
- func (s *Store) ForgetRepo(repo string) error
- func (s *Store) LoadComments(repo string, number int) (CommentCache, bool)
- func (s *Store) LoadMeta() Meta
- func (s *Store) LoadRepo(repo string) (RepoCache, error)
- func (s *Store) Paths() config.Paths
- func (s *Store) Pending() ([]Op, error)
- func (s *Store) Release(op Op) error
- func (s *Store) SaveComments(repo string, number int, cache CommentCache) error
- func (s *Store) SaveMeta(meta Meta) error
- func (s *Store) SaveRepo(cache RepoCache) error
- func (s *Store) Update(op Op) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Comment ¶
type Comment struct {
Author string `json:"author"`
Body string `json:"body"`
CreatedAt time.Time `json:"created_at"`
URL string `json:"url,omitempty"`
}
Comment is a cached issue comment.
type CommentCache ¶
type CommentCache struct {
IssueUpdatedAt time.Time `json:"issue_updated_at"`
Comments []Comment `json:"comments"`
}
CommentCache holds an issue's comments as of the issue's UpdatedAt.
type Conflict ¶
type Conflict struct {
RemoteTitle *string `json:"remote_title,omitempty"`
RemoteBody *string `json:"remote_body,omitempty"`
}
Conflict records the remote values that clash with an edit.
type Meta ¶
type Meta struct {
Login string `json:"login,omitempty"`
}
Meta is small cached state that isn't tied to a repository.
type Op ¶
type Op struct {
ID string `json:"id"`
Kind OpKind `json:"kind"`
Repo string `json:"repo"`
Number int `json:"number,omitempty"`
LocalID string `json:"local_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
// Create and edit. For edits, nil means unchanged and Base* hold the
// values the user started from, used to detect conflicting remote edits.
Title *string `json:"title,omitempty"`
Body *string `json:"body,omitempty"`
BaseTitle *string `json:"base_title,omitempty"`
BaseBody *string `json:"base_body,omitempty"`
Labels []string `json:"labels,omitempty"`
Assignees []string `json:"assignees,omitempty"`
// Labels and assign.
Add []string `json:"add,omitempty"`
Remove []string `json:"remove,omitempty"`
// State.
State string `json:"state,omitempty"`
StateReason string `json:"state_reason,omitempty"`
// Comment.
Comment string `json:"comment,omitempty"`
// Error is set when GitHub rejected the op; it's held until the user
// retries or discards it.
Error string `json:"error,omitempty"`
// Conflict is set when the issue changed on GitHub in a way that clashes
// with this edit.
Conflict *Conflict `json:"conflict,omitempty"`
Attempts int `json:"attempts,omitempty"`
// contains filtered or unexported fields
}
Op is one change waiting to be sent to GitHub. Ops target an issue by Number, or by LocalID when the issue was created in triage and hasn't reached GitHub yet.
type RepoCache ¶
type RepoCache struct {
Repo string `json:"repo"`
// ETag and Watermark identify the last issue listing so the next refresh
// only asks for issues updated since then.
ETag string `json:"etag,omitempty"`
Watermark time.Time `json:"watermark,omitempty"`
FetchedAt time.Time `json:"fetched_at,omitempty"`
Issues []issue.Issue `json:"issues"`
Labels []gh.Label `json:"labels,omitempty"`
}
RepoCache is everything triage remembers about one repository.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store reads and writes triage's local files.
func (*Store) Claim ¶
Claim marks op as being sent by this process. It returns false when the op is already claimed or gone, in which case the caller must leave it alone.
func (*Store) ClaimOp ¶
ClaimOp claims an op and returns its current contents, which may be newer than a copy read earlier by Pending.
func (*Store) Discard ¶
Discard deletes an op that isn't being sent. It returns false when the op was claimed by someone else or no longer exists.
func (*Store) ForgetRepo ¶
ForgetRepo deletes everything cached for repo.
func (*Store) LoadComments ¶
func (s *Store) LoadComments(repo string, number int) (CommentCache, bool)
LoadComments returns cached comments; ok is false when nothing is cached.
func (*Store) Pending ¶
Pending returns every op in the outbox, oldest first, including ops being sent by another process. Claims that have gone stale are released.
func (*Store) SaveComments ¶
func (s *Store) SaveComments(repo string, number int, cache CommentCache) error