1package cache
 2
 3import "github.com/git-bug/git-bug/entity"
 4
 5type BuildEventType int
 6
 7const (
 8	_ BuildEventType = iota
 9	// BuildEventCacheIsBuilt signal that the cache is being built (aka, not skipped)
10	BuildEventCacheIsBuilt
11	// BuildEventRemoveLock signal that an old repo lock has been cleaned
12	BuildEventRemoveLock
13	// BuildEventStarted signal the beginning of a cache build for an entity
14	BuildEventStarted
15	// BuildEventProgress signal progress in the cache building for an entity
16	BuildEventProgress
17	// BuildEventFinished signal the end of a cache build for an entity
18	BuildEventFinished
19)
20
21// BuildEvent carry an event happening during the cache build process.
22type BuildEvent struct {
23	// Err carry an error if the build process failed. If set, no other field matters.
24	Err error
25	// Typename is the name of the entity of which the event relate to. Can be empty if no particular entity is involved.
26	Typename string
27	// Event is the type of the event.
28	Event BuildEventType
29	// Total is the total number of elements being built. Set if Event is BuildEventStarted.
30	Total int64
31	// Progress is the current count of processed elements. Set if Event is BuildEventProgress.
32	Progress int64
33}
34
35type EntityEventType int
36
37const (
38	_ EntityEventType = iota
39	EntityEventCreated
40	EntityEventUpdated
41	EntityEventRemoved
42)
43
44// Observer gets notified of changes in entities in the cache
45type Observer interface {
46	EntityEvent(event EntityEventType, repoRef string, typename string, id entity.Id)
47}