cache

package
v0.0.0-...-8ec1dd0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2018 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package cache contains a caching layer on top of the low-level bug functions to provide efficient querying, filtering, sorting.

Index

Constants

This section is empty.

Variables

View Source
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 NewBugCache

func NewBugCache(repoCache *RepoCache, b *bug.Bug) *BugCache

func (*BugCache) AddComment

func (c *BugCache) AddComment(message string) error

func (*BugCache) AddCommentRaw

func (c *BugCache) AddCommentRaw(author bug.Person, unixTime int64, message string, files []git.Hash, metadata map[string]string) error

func (*BugCache) AddCommentWithFiles

func (c *BugCache) AddCommentWithFiles(message string, files []git.Hash) error

func (*BugCache) ChangeLabels

func (c *BugCache) ChangeLabels(added []string, removed []string) ([]bug.LabelChangeResult, error)

func (*BugCache) ChangeLabelsRaw

func (c *BugCache) ChangeLabelsRaw(author bug.Person, unixTime int64, added []string, removed []string, metadata map[string]string) ([]bug.LabelChangeResult, error)

func (*BugCache) Close

func (c *BugCache) Close() error

func (*BugCache) CloseRaw

func (c *BugCache) CloseRaw(author bug.Person, unixTime int64, metadata map[string]string) error

func (*BugCache) Commit

func (c *BugCache) Commit() error

func (*BugCache) CommitAsNeeded

func (c *BugCache) CommitAsNeeded() error

func (*BugCache) EditComment

func (c *BugCache) EditComment(target git.Hash, message string) error

func (*BugCache) EditCommentRaw

func (c *BugCache) EditCommentRaw(author bug.Person, unixTime int64, target git.Hash, message string, metadata map[string]string) error

func (*BugCache) HumanId

func (c *BugCache) HumanId() string

func (*BugCache) Id

func (c *BugCache) Id() string

func (*BugCache) Open

func (c *BugCache) Open() error

func (*BugCache) OpenRaw

func (c *BugCache) OpenRaw(author bug.Person, unixTime int64, metadata map[string]string) error

func (*BugCache) ResolveTargetWithMetadata

func (c *BugCache) ResolveTargetWithMetadata(key string, value string) (git.Hash, error)

ResolveTargetWithMetadata will find an operation that has the matching metadata

func (*BugCache) SetTitle

func (c *BugCache) SetTitle(title string) error

func (*BugCache) SetTitleRaw

func (c *BugCache) SetTitleRaw(author bug.Person, unixTime int64, title string, metadata map[string]string) error

func (*BugCache) Snapshot

func (c *BugCache) Snapshot() *bug.Snapshot

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

func (BugsById) Len

func (b BugsById) Len() int

func (BugsById) Less

func (b BugsById) Less(i, j int) bool

func (BugsById) Swap

func (b BugsById) Swap(i, j int)

type ErrMultipleMatchOp

type ErrMultipleMatchOp struct {
	Matching []git.Hash
}

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

func AuthorFilter(query string) Filter

AuthorFilter return a Filter that match a bug author

func LabelFilter

func LabelFilter(label string) Filter

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

func StatusFilter(query string) (Filter, error)

StatusFilter return a Filter that match a bug status

type Filters

type Filters struct {
	Status    []Filter
	Author    []Filter
	Label     []Filter
	NoFilters []Filter
}

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 OrderBy

type OrderBy int
const (
	OrderById OrderBy
	OrderByCreation
	OrderByEdit
)

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

func ParseQuery(query string) (*Query, error)

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

func (c *RepoCache) AllBugsIds() []string

AllBugsIds return all known bug ids

func (*RepoCache) ClearAllBugs

func (c *RepoCache) ClearAllBugs()

ClearAllBugs clear all bugs kept in memory

func (*RepoCache) Close

func (c *RepoCache) Close() error

func (*RepoCache) Fetch

func (c *RepoCache) Fetch(remote string) (string, error)

Fetch retrieve update from a remote This does not change the local bugs state

func (*RepoCache) GetCoreEditor

func (c *RepoCache) GetCoreEditor() (string, error)

GetPath returns the path to the repo.

func (*RepoCache) GetPath

func (c *RepoCache) GetPath() string

GetPath returns the path to the repo.

func (*RepoCache) GetUserEmail

func (c *RepoCache) GetUserEmail() (string, error)

GetUserEmail returns the email address that the user has used to configure git.

func (*RepoCache) GetUserName

func (c *RepoCache) GetUserName() (string, error)

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

func (c *RepoCache) NewBug(title string, message string) (*BugCache, error)

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) Push

func (c *RepoCache) Push(remote string) (string, error)

Push update a remote with the local changes

func (*RepoCache) QueryBugs

func (c *RepoCache) QueryBugs(query *Query) []string

func (*RepoCache) ReadConfigs

func (c *RepoCache) ReadConfigs(keyPrefix string) (map[string]string, error)

ReadConfigs read all key/value pair matching the key prefix

func (*RepoCache) ResolveBug

func (c *RepoCache) ResolveBug(id string) (*BugCache, error)

ResolveBug retrieve a bug matching the exact given id

func (*RepoCache) ResolveBugCreateMetadata

func (c *RepoCache) ResolveBugCreateMetadata(key string, value string) (*BugCache, error)

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

func (c *RepoCache) ResolveBugPrefix(prefix string) (*BugCache, error)

ResolveBugPrefix retrieve a bug matching an id prefix. It fails if multiple bugs match.

func (*RepoCache) RmConfigs

func (c *RepoCache) RmConfigs(keyPrefix string) error

RmConfigs remove all key/value pair matching the key prefix

func (*RepoCache) StoreConfig

func (c *RepoCache) StoreConfig(key string, value string) error

StoreConfig store a single key/value pair in the config of the repo

func (*RepoCache) ValidLabels

func (c *RepoCache) ValidLabels() []bug.Label

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.

Jump to

Keyboard shortcuts

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