* add wrapper reporter to append project details to chunk metadata * use cache to store project details * revert unnecessary change * delete from cache when done with scanning in ChunkUnit, implement PR suggestions * query project details using repo instead of having it in source unit * revert removal of build tag * Incorporated PR comments
30 lines
431 B
Go
30 lines
431 B
Go
package gitlab
|
|
|
|
import "sync"
|
|
|
|
type project struct {
|
|
id int
|
|
name string
|
|
owner string
|
|
}
|
|
|
|
type repoToProjectCache struct {
|
|
sync.RWMutex
|
|
|
|
cache map[string]*project
|
|
}
|
|
|
|
func (r *repoToProjectCache) get(repo string) (*project, bool) {
|
|
r.RLock()
|
|
defer r.RUnlock()
|
|
proj, ok := r.cache[repo]
|
|
return proj, ok
|
|
}
|
|
|
|
func (r *repoToProjectCache) set(repo string, proj *project) {
|
|
r.Lock()
|
|
defer r.Unlock()
|
|
|
|
r.cache[repo] = proj
|
|
}
|