Documentation ¶
Overview ¶
Package cache contains a caching layer on top of the low-level bug functions to provide efficient querying, filtering, sorting.
Index ¶
- Variables
- type BugCache
- func (c *BugCache) AddComment(message string) error
- func (c *BugCache) AddCommentRaw(author bug.Person, unixTime int64, message string, files []git.Hash, ...) error
- func (c *BugCache) AddCommentWithFiles(message string, files []git.Hash) error
- func (c *BugCache) ChangeLabels(added []string, removed []string) ([]bug.LabelChangeResult, error)
- func (c *BugCache) ChangeLabelsRaw(author bug.Person, unixTime int64, added []string, removed []string, ...) ([]bug.LabelChangeResult, error)
- func (c *BugCache) Close() error
- func (c *BugCache) CloseRaw(author bug.Person, unixTime int64, metadata map[string]string) error
- func (c *BugCache) Commit() error
- func (c *BugCache) CommitAsNeeded() error
- func (c *BugCache) EditComment(target git.Hash, message string) error
- func (c *BugCache) EditCommentRaw(author bug.Person, unixTime int64, target git.Hash, message string, ...) error
- func (c *BugCache) HumanId() string
- func (c *BugCache) Id() string
- func (c *BugCache) Open() error
- func (c *BugCache) OpenRaw(author bug.Person, unixTime int64, metadata map[string]string) error
- func (c *BugCache) ResolveTargetWithMetadata(key string, value string) (git.Hash, error)
- func (c *BugCache) SetTitle(title string) error
- func (c *BugCache) SetTitleRaw(author bug.Person, unixTime int64, title string, metadata map[string]string) error
- func (c *BugCache) Snapshot() *bug.Snapshot
- type BugExcerpt
- type BugsByCreationTime
- type BugsByEditTime
- type BugsById
- type ErrMultipleMatchOp
- type Filter
- type Filters
- type MultiRepoCache
- func (c *MultiRepoCache) Close() error
- func (c *MultiRepoCache) DefaultRepo() (*RepoCache, error)
- func (c *MultiRepoCache) RegisterDefaultRepository(repo repository.ClockedRepo) error
- func (c *MultiRepoCache) RegisterRepository(ref string, repo repository.ClockedRepo) error
- func (c *MultiRepoCache) ResolveRepo(ref string) (*RepoCache, error)
- type OrderBy
- type OrderDirection
- type Query
- type RepoCache
- func (c *RepoCache) AllBugsIds() []string
- func (c *RepoCache) ClearAllBugs()
- func (c *RepoCache) Close() error
- func (c *RepoCache) Fetch(remote string) (string, error)
- func (c *RepoCache) GetCoreEditor() (string, error)
- func (c *RepoCache) GetPath() string
- func (c *RepoCache) GetUserEmail() (string, error)
- func (c *RepoCache) GetUserName() (string, error)
- func (c *RepoCache) MergeAll(remote string) <-chan bug.MergeResult
- func (c *RepoCache) NewBug(title string, message string) (*BugCache, error)
- func (c *RepoCache) NewBugRaw(author bug.Person, unixTime int64, title string, message string, ...) (*BugCache, error)
- func (c *RepoCache) NewBugWithFiles(title string, message string, files []git.Hash) (*BugCache, error)
- func (c *RepoCache) Push(remote string) (string, error)
- func (c *RepoCache) QueryBugs(query *Query) []string
- func (c *RepoCache) ReadConfigs(keyPrefix string) (map[string]string, error)
- func (c *RepoCache) ResolveBug(id string) (*BugCache, error)
- func (c *RepoCache) ResolveBugCreateMetadata(key string, value string) (*BugCache, error)
- func (c *RepoCache) ResolveBugPrefix(prefix string) (*BugCache, error)
- func (c *RepoCache) RmConfigs(keyPrefix string) error
- func (c *RepoCache) StoreConfig(key string, value string) error
- func (c *RepoCache) ValidLabels() []bug.Label
Constants ¶
This section is empty.
Variables ¶
var ErrNoMatchingOp = fmt.Errorf("no matching operation found")
Functions ¶
This section is empty.
Types ¶
type BugCache ¶
type BugCache struct {
// contains filtered or unexported fields
}
func (*BugCache) AddComment ¶
func (*BugCache) AddCommentRaw ¶
func (*BugCache) AddCommentWithFiles ¶
func (*BugCache) ChangeLabels ¶
func (*BugCache) ChangeLabelsRaw ¶
func (*BugCache) CommitAsNeeded ¶
func (*BugCache) EditComment ¶
func (*BugCache) EditCommentRaw ¶
func (*BugCache) ResolveTargetWithMetadata ¶
ResolveTargetWithMetadata will find an operation that has the matching metadata
func (*BugCache) SetTitleRaw ¶
type BugExcerpt ¶
type BugExcerpt struct { Id string CreateLamportTime lamport.Time EditLamportTime lamport.Time CreateUnixTime int64 EditUnixTime int64 Status bug.Status Author bug.Person Labels []bug.Label CreateMetadata map[string]string }
BugExcerpt hold a subset of the bug values to be able to sort and filter bugs efficiently without having to read and compile each raw bugs.
func NewBugExcerpt ¶
func NewBugExcerpt(b bug.Interface, snap *bug.Snapshot) *BugExcerpt
type BugsByCreationTime ¶
type BugsByCreationTime []*BugExcerpt
func (BugsByCreationTime) Len ¶
func (b BugsByCreationTime) Len() int
func (BugsByCreationTime) Less ¶
func (b BugsByCreationTime) Less(i, j int) bool
func (BugsByCreationTime) Swap ¶
func (b BugsByCreationTime) Swap(i, j int)
type BugsByEditTime ¶
type BugsByEditTime []*BugExcerpt
func (BugsByEditTime) Len ¶
func (b BugsByEditTime) Len() int
func (BugsByEditTime) Less ¶
func (b BugsByEditTime) Less(i, j int) bool
func (BugsByEditTime) Swap ¶
func (b BugsByEditTime) Swap(i, j int)
type BugsById ¶
type BugsById []*BugExcerpt
type ErrMultipleMatchOp ¶
func (ErrMultipleMatchOp) Error ¶
func (e ErrMultipleMatchOp) Error() string
type Filter ¶
type Filter func(excerpt *BugExcerpt) bool
Filter is a functor that match a subset of bugs
func AuthorFilter ¶
AuthorFilter return a Filter that match a bug author
func LabelFilter ¶
LabelFilter return a Filter that match a label
func NoLabelFilter ¶
func NoLabelFilter() Filter
NoLabelFilter return a Filter that match the absence of labels
func StatusFilter ¶
StatusFilter return a Filter that match a bug status
type Filters ¶
Filters is a collection of Filter that implement a complex filter
func (*Filters) Match ¶
func (f *Filters) Match(excerpt *BugExcerpt) bool
Match check if a bug match the set of filters
type MultiRepoCache ¶
type MultiRepoCache struct {
// contains filtered or unexported fields
}
func NewMultiRepoCache ¶
func NewMultiRepoCache() MultiRepoCache
func (*MultiRepoCache) Close ¶
func (c *MultiRepoCache) Close() error
Close will do anything that is needed to close the cache properly
func (*MultiRepoCache) DefaultRepo ¶
func (c *MultiRepoCache) DefaultRepo() (*RepoCache, error)
ResolveRepo retrieve a repository by name
func (*MultiRepoCache) RegisterDefaultRepository ¶
func (c *MultiRepoCache) RegisterDefaultRepository(repo repository.ClockedRepo) error
RegisterDefaultRepository register a unnamed repository. Use this for mono-repo setup
func (*MultiRepoCache) RegisterRepository ¶
func (c *MultiRepoCache) RegisterRepository(ref string, repo repository.ClockedRepo) error
RegisterRepository register a named repository. Use this for multi-repo setup
func (*MultiRepoCache) ResolveRepo ¶
func (c *MultiRepoCache) ResolveRepo(ref string) (*RepoCache, error)
DefaultRepo retrieve the default repository
type OrderDirection ¶
type OrderDirection int
const ( OrderAscending OrderDirection OrderDescending )
type Query ¶
type Query struct { Filters OrderBy OrderDirection }
func NewQuery ¶
func NewQuery() *Query
Return an identity query with default sorting (creation-desc)
func ParseQuery ¶
ParseQuery parse a query DSL
Ex: "status:open author:descartes sort:edit-asc"
Supported filter qualifiers and syntax are described in docs/queries.md
type RepoCache ¶
type RepoCache struct {
// contains filtered or unexported fields
}
func NewRepoCache ¶
func NewRepoCache(r repository.ClockedRepo) (*RepoCache, error)
func (*RepoCache) AllBugsIds ¶
AllBugsIds return all known bug ids
func (*RepoCache) ClearAllBugs ¶
func (c *RepoCache) ClearAllBugs()
ClearAllBugs clear all bugs kept in memory
func (*RepoCache) Fetch ¶
Fetch retrieve update from a remote This does not change the local bugs state
func (*RepoCache) GetCoreEditor ¶
GetPath returns the path to the repo.
func (*RepoCache) GetUserEmail ¶
GetUserEmail returns the email address that the user has used to configure git.
func (*RepoCache) GetUserName ¶
GetUserName returns the name the the user has used to configure git
func (*RepoCache) MergeAll ¶
func (c *RepoCache) MergeAll(remote string) <-chan bug.MergeResult
MergeAll will merge all the available remote bug
func (*RepoCache) NewBug ¶
NewBug create a new bug The new bug is written in the repository (commit)
func (*RepoCache) NewBugRaw ¶
func (c *RepoCache) NewBugRaw(author bug.Person, unixTime int64, title string, message string, files []git.Hash, metadata map[string]string) (*BugCache, error)
NewBugWithFilesMeta create a new bug with attached files for the message, as well as metadata for the Create operation. The new bug is written in the repository (commit)
func (*RepoCache) NewBugWithFiles ¶
func (c *RepoCache) NewBugWithFiles(title string, message string, files []git.Hash) (*BugCache, error)
NewBugWithFiles create a new bug with attached files for the message The new bug is written in the repository (commit)
func (*RepoCache) ReadConfigs ¶
ReadConfigs read all key/value pair matching the key prefix
func (*RepoCache) ResolveBug ¶
ResolveBug retrieve a bug matching the exact given id
func (*RepoCache) ResolveBugCreateMetadata ¶
ResolveBugCreateMetadata retrieve a bug that has the exact given metadata on its Create operation, that is, the first operation. It fails if multiple bugs match.
func (*RepoCache) ResolveBugPrefix ¶
ResolveBugPrefix retrieve a bug matching an id prefix. It fails if multiple bugs match.
func (*RepoCache) StoreConfig ¶
StoreConfig store a single key/value pair in the config of the repo
func (*RepoCache) ValidLabels ¶
ValidLabels list valid labels
Note: in the future, a proper label policy could be implemented where valid labels are defined in a configuration file. Until that, the default behavior is to return the list of labels already used.