Documentation
¶
Overview ¶
Package cache contains a caching layer on top of the low-level bug and identity functions to provide efficient querying, filtering, sorting.
Index ¶
- Variables
- type Actions
- type BugCache
- func (c *BugCache) AddComment(message string) (entity.CombinedId, *bug.AddCommentOperation, error)
- func (c *BugCache) AddCommentRaw(author identity.Interface, unixTime int64, message string, ...) (entity.CombinedId, *bug.AddCommentOperation, error)
- func (c *BugCache) AddCommentWithFiles(message string, files []repository.Hash) (entity.CombinedId, *bug.AddCommentOperation, error)
- func (c *BugCache) ChangeLabels(added []string, removed []string) ([]bug.LabelChangeResult, *bug.LabelChangeOperation, error)
- func (c *BugCache) ChangeLabelsRaw(author identity.Interface, unixTime int64, added []string, removed []string, ...) ([]bug.LabelChangeResult, *bug.LabelChangeOperation, error)
- func (c *BugCache) Close() (*bug.SetStatusOperation, error)
- func (c *BugCache) CloseRaw(author identity.Interface, unixTime int64, metadata map[string]string) (*bug.SetStatusOperation, error)
- func (c *BugCache) EditComment(target entity.CombinedId, message string) (*bug.EditCommentOperation, error)
- func (c *BugCache) EditCommentRaw(author identity.Interface, unixTime int64, target entity.CombinedId, ...) (*bug.EditCommentOperation, error)
- func (c *BugCache) EditCreateComment(body string) (entity.CombinedId, *bug.EditCommentOperation, error)
- func (c *BugCache) EditCreateCommentRaw(author identity.Interface, unixTime int64, body string, ...) (entity.CombinedId, *bug.EditCommentOperation, error)
- func (c *BugCache) ForceChangeLabels(added []string, removed []string) (*bug.LabelChangeOperation, error)
- func (c *BugCache) ForceChangeLabelsRaw(author identity.Interface, unixTime int64, added []string, removed []string, ...) (*bug.LabelChangeOperation, error)
- func (c *BugCache) Open() (*bug.SetStatusOperation, error)
- func (c *BugCache) OpenRaw(author identity.Interface, unixTime int64, metadata map[string]string) (*bug.SetStatusOperation, error)
- func (c *BugCache) SetMetadata(target entity.Id, newMetadata map[string]string) (*dag.SetMetadataOperation[*bug.Snapshot], error)
- func (c *BugCache) SetMetadataRaw(author identity.Interface, unixTime int64, target entity.Id, ...) (*dag.SetMetadataOperation[*bug.Snapshot], error)
- func (c *BugCache) SetTitle(title string) (*bug.SetTitleOperation, error)
- func (c *BugCache) SetTitleRaw(author identity.Interface, unixTime int64, title string, ...) (*bug.SetTitleOperation, error)
- type BugExcerpt
- type BugsByCreationTime
- type BugsByEditTime
- type BugsById
- type BuildEvent
- type BuildEventType
- type CacheEntity
- type CachedEntityBase
- func (e *CachedEntityBase[SnapT, OpT]) Commit() error
- func (e *CachedEntityBase[SnapT, OpT]) CommitAsNeeded() error
- func (e *CachedEntityBase[SnapT, OpT]) CreateLamportTime() lamport.Time
- func (e *CachedEntityBase[SnapT, OpT]) EditLamportTime() lamport.Time
- func (e *CachedEntityBase[SnapT, OpT]) FirstOp() OpT
- func (e *CachedEntityBase[SnapT, OpT]) Id() entity.Id
- func (e *CachedEntityBase[SnapT, OpT]) Lock()
- func (e *CachedEntityBase[SnapT, OpT]) NeedCommit() bool
- func (e *CachedEntityBase[SnapT, OpT]) ResolveOperationWithMetadata(key string, value string) (entity.Id, error)
- func (e *CachedEntityBase[SnapT, OpT]) Snapshot() SnapT
- func (e *CachedEntityBase[SnapT, OpT]) Validate() error
- type Excerpt
- type Filter
- func ActorFilter(query string) Filter
- func AuthorFilter(query string) Filter
- func LabelFilter(label string) Filter
- func MetadataFilter(pair query.StringPair) Filter
- func NoLabelFilter() Filter
- func ParticipantFilter(query string) Filter
- func StatusFilter(status common.Status) Filter
- func TitleFilter(query string) Filter
- type IdentityById
- type IdentityCache
- type IdentityExcerpt
- type Matcher
- type MultiRepoCache
- func (c *MultiRepoCache) Close() error
- func (c *MultiRepoCache) DefaultRepo() (*RepoCache, error)
- func (c *MultiRepoCache) RegisterDefaultRepository(repo repository.ClockedRepo) (*RepoCache, chan BuildEvent)
- func (c *MultiRepoCache) RegisterRepository(repo repository.ClockedRepo, name string) (*RepoCache, chan BuildEvent)
- func (c *MultiRepoCache) ResolveRepo(name string) (*RepoCache, error)
- type RepoCache
- func (c *RepoCache) AnyConfig() repository.ConfigRead
- func (c *RepoCache) Bugs() *RepoCacheBug
- func (c *RepoCache) ClearUserIdentity() error
- func (c *RepoCache) Close() error
- func (c *RepoCache) Fetch(remote string) (string, error)
- func (c *RepoCache) GetCoreEditor() (string, error)
- func (c *RepoCache) GetRemotes() (map[string]string, error)
- func (c *RepoCache) GetUserEmail() (string, error)
- func (c *RepoCache) GetUserIdentity() (*IdentityCache, error)
- func (c *RepoCache) GetUserIdentityExcerpt() (*IdentityExcerpt, error)
- func (c *RepoCache) GetUserName() (string, error)
- func (c *RepoCache) GlobalConfig() repository.Config
- func (c *RepoCache) Identities() *RepoCacheIdentity
- func (c *RepoCache) IsUserIdentitySet() (bool, error)
- func (c *RepoCache) Keyring() repository.Keyring
- func (c *RepoCache) LocalConfig() repository.Config
- func (c *RepoCache) LocalStorage() repository.LocalStorage
- func (c *RepoCache) MergeAll(remote string) <-chan entity.MergeResult
- func (c *RepoCache) Name() string
- func (c *RepoCache) Pull(remote string) error
- func (c *RepoCache) Push(remote string) (string, error)
- func (c *RepoCache) ReadData(hash repository.Hash) ([]byte, error)
- func (c *RepoCache) RemoveAll() error
- func (c *RepoCache) SetUserIdentity(i *IdentityCache) error
- func (c *RepoCache) StoreData(data []byte) (repository.Hash, error)
- type RepoCacheBug
- func (c *RepoCacheBug) New(title string, message string) (*BugCache, *bug.CreateOperation, error)
- func (c *RepoCacheBug) NewRaw(author identity.Interface, unixTime int64, title string, message string, ...) (*BugCache, *bug.CreateOperation, error)
- func (c *RepoCacheBug) NewWithFiles(title string, message string, files []repository.Hash) (*BugCache, *bug.CreateOperation, error)
- func (c *RepoCacheBug) Query(q *query.Query) ([]entity.Id, error)
- func (c *RepoCacheBug) ResolveBugCreateMetadata(key string, value string) (*BugCache, error)
- func (c *RepoCacheBug) ResolveComment(prefix string) (*BugCache, entity.CombinedId, error)
- func (c *RepoCacheBug) ValidLabels() []common.Label
- type RepoCacheIdentity
- func (c *RepoCacheIdentity) New(name string, email string) (*IdentityCache, error)
- func (c *RepoCacheIdentity) NewFromGitUser() (*IdentityCache, error)
- func (c *RepoCacheIdentity) NewFromGitUserRaw(metadata map[string]string) (*IdentityCache, error)
- func (c *RepoCacheIdentity) NewFull(name string, email string, login string, avatarUrl string, ...) (*IdentityCache, error)
- func (c *RepoCacheIdentity) NewRaw(name string, email string, login string, avatarUrl string, ...) (*IdentityCache, error)
- func (c *RepoCacheIdentity) ResolveIdentityImmutableMetadata(key string, value string) (*IdentityCache, error)
- type SubCache
- func (sc *SubCache[EntityT, ExcerptT, CacheT]) AllIds() []entity.Id
- func (sc *SubCache[EntityT, ExcerptT, CacheT]) Build() <-chan BuildEvent
- func (sc *SubCache[EntityT, ExcerptT, CacheT]) Close() error
- func (sc *SubCache[EntityT, ExcerptT, CacheT]) GetNamespace() string
- func (sc *SubCache[EntityT, ExcerptT, CacheT]) Load() error
- func (sc *SubCache[EntityT, ExcerptT, CacheT]) MergeAll(remote string) <-chan entity.MergeResult
- func (sc *SubCache[EntityT, ExcerptT, CacheT]) Remove(prefix string) error
- func (sc *SubCache[EntityT, ExcerptT, CacheT]) RemoveAll() error
- func (sc *SubCache[EntityT, ExcerptT, CacheT]) Resolve(id entity.Id) (CacheT, error)
- func (sc *SubCache[EntityT, ExcerptT, CacheT]) ResolveExcerpt(id entity.Id) (ExcerptT, error)
- func (sc *SubCache[EntityT, ExcerptT, CacheT]) ResolveExcerptMatcher(f func(ExcerptT) bool) (ExcerptT, error)
- func (sc *SubCache[EntityT, ExcerptT, CacheT]) ResolveExcerptPrefix(prefix string) (ExcerptT, error)
- func (sc *SubCache[EntityT, ExcerptT, CacheT]) ResolveMatcher(f func(ExcerptT) bool) (CacheT, error)
- func (sc *SubCache[EntityT, ExcerptT, CacheT]) ResolvePrefix(prefix string) (CacheT, error)
- func (sc *SubCache[EntityT, ExcerptT, CacheT]) SetCacheSize(size int)
- func (sc *SubCache[EntityT, ExcerptT, CacheT]) Typename() string
Constants ¶
This section is empty.
Variables ¶
var ErrNoMatchingOp = fmt.Errorf("no matching operation found")
Functions ¶
This section is empty.
Types ¶
type Actions ¶
type Actions[EntityT entity.Interface] struct { ReadWithResolver func(repo repository.ClockedRepo, resolvers entity.Resolvers, id entity.Id) (EntityT, error) ReadAllWithResolver func(repo repository.ClockedRepo, resolvers entity.Resolvers) <-chan entity.StreamedEntity[EntityT] Remove func(repo repository.ClockedRepo, id entity.Id) error RemoveAll func(repo repository.ClockedRepo) error MergeAll func(repo repository.ClockedRepo, resolvers entity.Resolvers, remote string, mergeAuthor identity.Interface) <-chan entity.MergeResult }
Actions expose a number of action functions on Entities, to give upper layers (cache) a way to normalize interactions. Note: ideally this wouldn't exist, the cache layer would assume that everything is an entity/dag, and directly use the functions from this package, but right now identities are not using that framework.
type BugCache ¶
type BugCache struct {
CachedEntityBase[*bug.Snapshot, bug.Operation]
}
BugCache is a wrapper around a Bug. It provides multiple functions:
1. Provide a higher level API to use than the raw API from Bug. 2. Maintain an up-to-date Snapshot available. 3. Deal with concurrency.
func NewBugCache ¶
func NewBugCache(b *bug.Bug, repo repository.ClockedRepo, getUserIdentity getUserIdentityFunc, entityUpdated func(id entity.Id) error) *BugCache
func (*BugCache) AddComment ¶
func (c *BugCache) AddComment(message string) (entity.CombinedId, *bug.AddCommentOperation, error)
func (*BugCache) AddCommentRaw ¶
func (c *BugCache) AddCommentRaw(author identity.Interface, unixTime int64, message string, files []repository.Hash, metadata map[string]string) (entity.CombinedId, *bug.AddCommentOperation, error)
func (*BugCache) AddCommentWithFiles ¶
func (c *BugCache) AddCommentWithFiles(message string, files []repository.Hash) (entity.CombinedId, *bug.AddCommentOperation, error)
func (*BugCache) ChangeLabels ¶
func (c *BugCache) ChangeLabels(added []string, removed []string) ([]bug.LabelChangeResult, *bug.LabelChangeOperation, error)
func (*BugCache) ChangeLabelsRaw ¶
func (*BugCache) EditComment ¶
func (c *BugCache) EditComment(target entity.CombinedId, message string) (*bug.EditCommentOperation, error)
func (*BugCache) EditCommentRaw ¶
func (*BugCache) EditCreateComment ¶
func (c *BugCache) EditCreateComment(body string) (entity.CombinedId, *bug.EditCommentOperation, error)
EditCreateComment is a convenience function to edit the body of a bug (the first comment)
func (*BugCache) EditCreateCommentRaw ¶
func (c *BugCache) EditCreateCommentRaw(author identity.Interface, unixTime int64, body string, metadata map[string]string) (entity.CombinedId, *bug.EditCommentOperation, error)
EditCreateCommentRaw is a convenience function to edit the body of a bug (the first comment)
func (*BugCache) ForceChangeLabels ¶
func (*BugCache) ForceChangeLabelsRaw ¶
func (*BugCache) SetMetadata ¶
func (*BugCache) SetMetadataRaw ¶
type BugExcerpt ¶
type BugExcerpt struct {
CreateLamportTime lamport.Time
EditLamportTime lamport.Time
CreateUnixTime int64
EditUnixTime int64
AuthorId entity.Id
Status common.Status
Labels []common.Label
Title string
LenComments int
Actors []entity.Id
Participants []entity.Id
CreateMetadata map[string]string
// contains filtered or unexported fields
}
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 *BugCache) *BugExcerpt
func (*BugExcerpt) CreateTime ¶
func (b *BugExcerpt) CreateTime() time.Time
func (*BugExcerpt) EditTime ¶
func (b *BugExcerpt) EditTime() time.Time
func (*BugExcerpt) Id ¶
func (b *BugExcerpt) Id() entity.Id
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 BuildEvent ¶
type BuildEvent struct {
// Err carry an error if the build process failed. If set, no other field matter.
Err error
// Typename is the name of the entity of which the event relate to. Can be empty if not particular entity is involved.
Typename string
// Event is the type of the event.
Event BuildEventType
// Total is the total number of element being built. Set if Event is BuildEventStarted.
Total int64
// Progress is the current count of processed element. Set if Event is BuildEventProgress.
Progress int64
}
BuildEvent carry an event happening during the cache build process.
type BuildEventType ¶
type BuildEventType int
const ( // BuildEventCacheIsBuilt signal that the cache is being built (aka, not skipped) BuildEventCacheIsBuilt BuildEventType // BuildEventRemoveLock signal that an old repo lock has been cleaned BuildEventRemoveLock // BuildEventStarted signal the beginning of a cache build for an entity BuildEventStarted // BuildEventProgress signal progress in the cache building for an entity BuildEventProgress // BuildEventFinished signal the end of a cache build for an entity BuildEventFinished )
type CacheEntity ¶
type CachedEntityBase ¶
type CachedEntityBase[SnapT dag.Snapshot, OpT dag.Operation] struct { // contains filtered or unexported fields }
CachedEntityBase provide the base function of an entity managed by the cache.
func (*CachedEntityBase[SnapT, OpT]) Commit ¶
func (e *CachedEntityBase[SnapT, OpT]) Commit() error
func (*CachedEntityBase[SnapT, OpT]) CommitAsNeeded ¶
func (e *CachedEntityBase[SnapT, OpT]) CommitAsNeeded() error
func (*CachedEntityBase[SnapT, OpT]) CreateLamportTime ¶
func (e *CachedEntityBase[SnapT, OpT]) CreateLamportTime() lamport.Time
func (*CachedEntityBase[SnapT, OpT]) EditLamportTime ¶
func (e *CachedEntityBase[SnapT, OpT]) EditLamportTime() lamport.Time
func (*CachedEntityBase[SnapT, OpT]) FirstOp ¶
func (e *CachedEntityBase[SnapT, OpT]) FirstOp() OpT
func (*CachedEntityBase[SnapT, OpT]) Id ¶
func (e *CachedEntityBase[SnapT, OpT]) Id() entity.Id
func (*CachedEntityBase[SnapT, OpT]) Lock ¶
func (e *CachedEntityBase[SnapT, OpT]) Lock()
func (*CachedEntityBase[SnapT, OpT]) NeedCommit ¶
func (e *CachedEntityBase[SnapT, OpT]) NeedCommit() bool
func (*CachedEntityBase[SnapT, OpT]) ResolveOperationWithMetadata ¶
func (e *CachedEntityBase[SnapT, OpT]) ResolveOperationWithMetadata(key string, value string) (entity.Id, error)
ResolveOperationWithMetadata will find an operation that has the matching metadata
func (*CachedEntityBase[SnapT, OpT]) Snapshot ¶
func (e *CachedEntityBase[SnapT, OpT]) Snapshot() SnapT
func (*CachedEntityBase[SnapT, OpT]) Validate ¶
func (e *CachedEntityBase[SnapT, OpT]) Validate() error
type Filter ¶
type Filter func(excerpt *BugExcerpt, resolvers entity.Resolvers) bool
Filter is a predicate that match a subset of bugs
func ActorFilter ¶
ActorFilter return a Filter that match a bug actor
func AuthorFilter ¶
AuthorFilter return a Filter that match a bug author
func LabelFilter ¶
LabelFilter return a Filter that match a label
func MetadataFilter ¶
func MetadataFilter(pair query.StringPair) Filter
MetadataFilter return a Filter that match a bug metadata at creation time
func NoLabelFilter ¶
func NoLabelFilter() Filter
NoLabelFilter return a Filter that match the absence of labels
func ParticipantFilter ¶
ParticipantFilter return a Filter that match a bug participant
func StatusFilter ¶
StatusFilter return a Filter that match a bug status
func TitleFilter ¶
TitleFilter return a Filter that match if the title contains the given query
type IdentityById ¶
type IdentityById []*IdentityExcerpt
func (IdentityById) Len ¶
func (b IdentityById) Len() int
func (IdentityById) Less ¶
func (b IdentityById) Less(i, j int) bool
func (IdentityById) Swap ¶
func (b IdentityById) Swap(i, j int)
type IdentityCache ¶
IdentityCache is a wrapper around an Identity for caching.
func NewIdentityCache ¶
func NewIdentityCache(i *identity.Identity, repo repository.ClockedRepo, entityUpdated func(id entity.Id) error) *IdentityCache
func (*IdentityCache) Commit ¶
func (i *IdentityCache) Commit() error
func (*IdentityCache) CommitAsNeeded ¶
func (i *IdentityCache) CommitAsNeeded() error
func (*IdentityCache) Lock ¶
func (i *IdentityCache) Lock()
func (*IdentityCache) Mutate ¶
func (i *IdentityCache) Mutate(repo repository.RepoClock, f func(*identity.Mutator)) error
type IdentityExcerpt ¶
type IdentityExcerpt struct {
Name string
Login string
ImmutableMetadata map[string]string
// contains filtered or unexported fields
}
IdentityExcerpt hold a subset of the identity values to be able to sort and filter identities efficiently without having to read and compile each raw identity.
func NewIdentityExcerpt ¶
func NewIdentityExcerpt(i *IdentityCache) *IdentityExcerpt
func (*IdentityExcerpt) DisplayName ¶
func (i *IdentityExcerpt) DisplayName() string
DisplayName return a non-empty string to display, representing the identity, based on the non-empty values.
func (*IdentityExcerpt) Id ¶
func (i *IdentityExcerpt) Id() entity.Id
func (*IdentityExcerpt) Match ¶
func (i *IdentityExcerpt) Match(query string) bool
Match matches a query with the identity name, login and ID prefixes
type Matcher ¶
type Matcher struct {
Status []Filter
Author []Filter
Metadata []Filter
Actor []Filter
Participant []Filter
Label []Filter
Title []Filter
NoFilters []Filter
}
Matcher is a collection of Filter that implement a complex filter
type MultiRepoCache ¶
type MultiRepoCache struct {
// contains filtered or unexported fields
}
MultiRepoCache is the root cache, holding multiple RepoCache.
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)
DefaultRepo retrieve the default repository
func (*MultiRepoCache) RegisterDefaultRepository ¶
func (c *MultiRepoCache) RegisterDefaultRepository(repo repository.ClockedRepo) (*RepoCache, chan BuildEvent)
RegisterDefaultRepository register an unnamed repository. Use this for single-repo setup
func (*MultiRepoCache) RegisterRepository ¶
func (c *MultiRepoCache) RegisterRepository(repo repository.ClockedRepo, name string) (*RepoCache, chan BuildEvent)
RegisterRepository register a named repository. Use this for multi-repo setup
func (*MultiRepoCache) ResolveRepo ¶
func (c *MultiRepoCache) ResolveRepo(name string) (*RepoCache, error)
ResolveRepo retrieve a repository by name
type RepoCache ¶
type RepoCache struct {
// contains filtered or unexported fields
}
RepoCache is a cache for a Repository. This cache has multiple functions:
- After being loaded, a Bug is kept in memory in the cache, allowing for fast access later.
- The cache maintain in memory and on disk a pre-digested excerpt for each bug, allowing for fast querying the whole set of bugs without having to load them individually.
- The cache guarantee that a single instance of a Bug is loaded at once, avoiding loss of data that we could have with multiple copies in the same process.
- The same way, the cache maintain in memory a single copy of the loaded identities.
The cache also protect the on-disk data by locking the git repository for its own usage, by writing a lock file. Of course, normal git operations are not affected, only git-bug related one.
func NewNamedRepoCache ¶
func NewNamedRepoCache(r repository.ClockedRepo, name string) (*RepoCache, chan BuildEvent)
NewNamedRepoCache create or open a named cache on top of a raw repository. The caller is expected to read all returned events before the cache is considered ready to use.
func NewRepoCache ¶
func NewRepoCache(r repository.ClockedRepo) (*RepoCache, chan BuildEvent)
NewRepoCache create or open a cache on top of a raw repository. The caller is expected to read all returned events before the cache is considered ready to use.
func NewRepoCacheNoEvents ¶
func NewRepoCacheNoEvents(r repository.ClockedRepo) (*RepoCache, error)
func (*RepoCache) AnyConfig ¶
func (c *RepoCache) AnyConfig() repository.ConfigRead
AnyConfig give access to a merged local/global configuration
func (*RepoCache) Bugs ¶
func (c *RepoCache) Bugs() *RepoCacheBug
Bugs gives access to the Bug entities
func (*RepoCache) ClearUserIdentity ¶
func (*RepoCache) Fetch ¶
Fetch retrieve updates from a remote This does not change the local bugs or identities state
func (*RepoCache) GetCoreEditor ¶
GetCoreEditor returns the name of the editor that the user has used to configure git.
func (*RepoCache) GetRemotes ¶
GetRemotes returns the configured remotes repositories.
func (*RepoCache) GetUserEmail ¶
GetUserEmail returns the email address that the user has used to configure git.
func (*RepoCache) GetUserIdentity ¶
func (c *RepoCache) GetUserIdentity() (*IdentityCache, error)
func (*RepoCache) GetUserIdentityExcerpt ¶
func (c *RepoCache) GetUserIdentityExcerpt() (*IdentityExcerpt, error)
func (*RepoCache) GetUserName ¶
GetUserName returns the name the user has used to configure git
func (*RepoCache) GlobalConfig ¶
func (c *RepoCache) GlobalConfig() repository.Config
GlobalConfig give access to the global scoped configuration
func (*RepoCache) Identities ¶
func (c *RepoCache) Identities() *RepoCacheIdentity
Identities gives access to the Identity entities
func (*RepoCache) IsUserIdentitySet ¶
func (*RepoCache) Keyring ¶
func (c *RepoCache) Keyring() repository.Keyring
Keyring give access to a user-wide storage for secrets
func (*RepoCache) LocalConfig ¶
func (c *RepoCache) LocalConfig() repository.Config
LocalConfig give access to the repository scoped configuration
func (*RepoCache) LocalStorage ¶
func (c *RepoCache) LocalStorage() repository.LocalStorage
LocalStorage return a billy.Filesystem giving access to $RepoPath/.git/git-bug
func (*RepoCache) MergeAll ¶
func (c *RepoCache) MergeAll(remote string) <-chan entity.MergeResult
MergeAll will merge all the available remote bug and identities
func (*RepoCache) Pull ¶
Pull will do a Fetch + MergeAll This function will return an error if a merge fail
func (*RepoCache) ReadData ¶
func (c *RepoCache) ReadData(hash repository.Hash) ([]byte, error)
ReadData will attempt to read arbitrary data from the given hash
func (*RepoCache) SetUserIdentity ¶
func (c *RepoCache) SetUserIdentity(i *IdentityCache) error
type RepoCacheBug ¶
type RepoCacheBug struct {
*SubCache[*bug.Bug, *BugExcerpt, *BugCache]
}
func NewRepoCacheBug ¶
func NewRepoCacheBug(repo repository.ClockedRepo, resolvers func() entity.Resolvers, getUserIdentity getUserIdentityFunc) *RepoCacheBug
func (*RepoCacheBug) New ¶
func (c *RepoCacheBug) New(title string, message string) (*BugCache, *bug.CreateOperation, error)
New create a new bug The new bug is written in the repository (commit)
func (*RepoCacheBug) NewRaw ¶
func (c *RepoCacheBug) NewRaw(author identity.Interface, unixTime int64, title string, message string, files []repository.Hash, metadata map[string]string) (*BugCache, *bug.CreateOperation, error)
NewRaw 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 (*RepoCacheBug) NewWithFiles ¶
func (c *RepoCacheBug) NewWithFiles(title string, message string, files []repository.Hash) (*BugCache, *bug.CreateOperation, error)
NewWithFiles create a new bug with attached files for the message The new bug is written in the repository (commit)
func (*RepoCacheBug) ResolveBugCreateMetadata ¶
func (c *RepoCacheBug) 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 (*RepoCacheBug) ResolveComment ¶
func (c *RepoCacheBug) ResolveComment(prefix string) (*BugCache, entity.CombinedId, error)
ResolveComment search for a Bug/Comment combination matching the merged bug/comment Id prefix. Returns the Bug containing the Comment and the Comment's Id.
func (*RepoCacheBug) ValidLabels ¶
func (c *RepoCacheBug) ValidLabels() []common.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.
type RepoCacheIdentity ¶
type RepoCacheIdentity struct {
*SubCache[*identity.Identity, *IdentityExcerpt, *IdentityCache]
}
func NewRepoCacheIdentity ¶
func NewRepoCacheIdentity(repo repository.ClockedRepo, resolvers func() entity.Resolvers, getUserIdentity getUserIdentityFunc) *RepoCacheIdentity
func (*RepoCacheIdentity) New ¶
func (c *RepoCacheIdentity) New(name string, email string) (*IdentityCache, error)
New create a new identity The new identity is written in the repository (commit)
func (*RepoCacheIdentity) NewFromGitUser ¶
func (c *RepoCacheIdentity) NewFromGitUser() (*IdentityCache, error)
func (*RepoCacheIdentity) NewFromGitUserRaw ¶
func (c *RepoCacheIdentity) NewFromGitUserRaw(metadata map[string]string) (*IdentityCache, error)
func (*RepoCacheIdentity) NewFull ¶
func (c *RepoCacheIdentity) NewFull(name string, email string, login string, avatarUrl string, keys []*identity.Key) (*IdentityCache, error)
NewFull create a new identity The new identity is written in the repository (commit)
func (*RepoCacheIdentity) ResolveIdentityImmutableMetadata ¶
func (c *RepoCacheIdentity) ResolveIdentityImmutableMetadata(key string, value string) (*IdentityCache, error)
ResolveIdentityImmutableMetadata retrieve an Identity that has the exact given metadata on one of its version. If multiple version have the same key, the first defined take precedence.
type SubCache ¶
type SubCache[EntityT entity.Interface, ExcerptT Excerpt, CacheT CacheEntity] struct { // contains filtered or unexported fields }
func NewSubCache ¶
func NewSubCache[EntityT entity.Interface, ExcerptT Excerpt, CacheT CacheEntity]( repo repository.ClockedRepo, resolvers func() entity.Resolvers, getUserIdentity getUserIdentityFunc, makeCached func(entity EntityT, entityUpdated func(id entity.Id) error) CacheT, makeExcerpt func(CacheT) ExcerptT, makeIndexData func(CacheT) []string, actions Actions[EntityT], typename, namespace string, version uint, maxLoaded int) *SubCache[EntityT, ExcerptT, CacheT]
func (*SubCache[EntityT, ExcerptT, CacheT]) Build ¶
func (sc *SubCache[EntityT, ExcerptT, CacheT]) Build() <-chan BuildEvent
func (*SubCache[EntityT, ExcerptT, CacheT]) GetNamespace ¶
func (*SubCache[EntityT, ExcerptT, CacheT]) Load ¶
Load will try to read from the disk the entity cache file
func (*SubCache[EntityT, ExcerptT, CacheT]) MergeAll ¶
func (sc *SubCache[EntityT, ExcerptT, CacheT]) MergeAll(remote string) <-chan entity.MergeResult
func (*SubCache[EntityT, ExcerptT, CacheT]) Resolve ¶
Resolve retrieve an entity matching the exact given id
func (*SubCache[EntityT, ExcerptT, CacheT]) ResolveExcerpt ¶
ResolveExcerpt retrieve an Excerpt matching the exact given id
func (*SubCache[EntityT, ExcerptT, CacheT]) ResolveExcerptMatcher ¶
func (*SubCache[EntityT, ExcerptT, CacheT]) ResolveExcerptPrefix ¶
func (sc *SubCache[EntityT, ExcerptT, CacheT]) ResolveExcerptPrefix(prefix string) (ExcerptT, error)
ResolveExcerptPrefix retrieve an Excerpt matching an id prefix. It fails if multiple entities match.
func (*SubCache[EntityT, ExcerptT, CacheT]) ResolveMatcher ¶
func (*SubCache[EntityT, ExcerptT, CacheT]) ResolvePrefix ¶
ResolvePrefix retrieve an entity matching an id prefix. It fails if multiple entities match.