stats for rill

This commit is contained in:
Jeff Carr 2025-08-31 15:05:40 -05:00
parent 46c11e7d33
commit 5147aa73de
1 changed files with 35 additions and 13 deletions

48
rill.go
View File

@ -154,11 +154,10 @@ func (f *Forge) RillFuncError(rillf func(*gitpb.Repo) error) int {
func (f *Forge) ConfigRill(rillX int, rillY int) {
}
type rillStats struct {
fullpath string
err error
start time.Time
end time.Time
type RillStats struct {
Err error
Start time.Time
End time.Time
}
var rillMu sync.Mutex
@ -167,14 +166,14 @@ var rillMu sync.Mutex
// y is how many simultanous functions will run
// todo: tune and compute x,y by # of CPUs and disk io
// todo: store x,y in forge config ? (or compute them. notsure)
func (f *Forge) RillRepos(rillf func(*gitpb.Repo) error) map[*gitpb.Repo]error {
func (f *Forge) RillRepos(rillf func(*gitpb.Repo) error) map[string]*RillStats {
var all []*gitpb.Repo
var allerr map[*gitpb.Repo]error
allerr = make(map[*gitpb.Repo]error)
var stats map[string]rillStats
stats = make(map[string]rillStats)
var stats map[string]*RillStats
stats = make(map[string]*RillStats)
for repo := range f.Repos.IterAll() {
if !repo.IsValidDir() {
@ -203,26 +202,49 @@ func (f *Forge) RillRepos(rillf func(*gitpb.Repo) error) map[*gitpb.Repo]error {
watch += 50
}
rillMu.Unlock()
rillSetStartTime(stats, repo.GetFullPath())
if err := rillf(repo); err != nil {
rillMu.Lock()
allerr[repo] = err
rillMu.Unlock()
rillSetError(stats, repo.GetFullPath(), err)
}
rillSetEndTime(stats, repo.GetFullPath())
return nil
})
return allerr
return stats
}
func rillSetError(stats map[string]rillStats, fullpath string, err error) {
func rillSetError(stats map[string]*RillStats, fullpath string, err error) {
rillMu.Lock()
defer rillMu.Unlock()
if s, ok := stats[fullpath]; ok {
s.err = err
s.Err = err
return
}
var s rillStats
s.err = err
log.Info("WHAT THE FUCK STATS ERROR", fullpath)
}
func rillSetStartTime(stats map[string]*RillStats, fullpath string) {
rillMu.Lock()
defer rillMu.Unlock()
if s, ok := stats[fullpath]; ok {
s.Start = time.Now()
return
}
var s *RillStats
s = new(RillStats)
s.Start = time.Now()
stats[fullpath] = s
}
func rillSetEndTime(stats map[string]*RillStats, fullpath string) {
rillMu.Lock()
defer rillMu.Unlock()
if s, ok := stats[fullpath]; ok {
s.End = time.Now()
return
}
log.Info("WHAT THE FUCK STATS END TIME", fullpath)
}