make stats for rill
This commit is contained in:
parent
eee996ed59
commit
46c11e7d33
|
@ -50,13 +50,13 @@ func (f *Forge) AddNamespaceDir(ns string, fullpath string) (*gitpb.Repo, error)
|
|||
log.Info("WARNING. NEW FAILED", fullpath)
|
||||
return nil, err
|
||||
}
|
||||
// slices.Reverse(f.Repos.Repos)
|
||||
|
||||
// repo.URL = url
|
||||
f.VerifyBranchNames(repo)
|
||||
repo.Reload()
|
||||
if err := repo.ValidateUTF8(); err != nil {
|
||||
return repo, err
|
||||
|
||||
// set the readonly flag based on the users' forge config
|
||||
if f.Config.IsReadOnly(repo.GetGoPath()) {
|
||||
repo.ReadOnly = true
|
||||
}
|
||||
return repo, nil
|
||||
}
|
||||
|
|
37
rill.go
37
rill.go
|
@ -2,6 +2,7 @@ package forgepb
|
|||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/destel/rill"
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
|
@ -68,7 +69,7 @@ func (f *Forge) updateRepo(repo *gitpb.Repo) error {
|
|||
}
|
||||
|
||||
var RillX int = 10
|
||||
var RillY int = 10
|
||||
var RillY int = 20
|
||||
|
||||
// x is the size of the queued up pool (shouldn't matter here for this I think)
|
||||
// y is how many simultanous functions will run
|
||||
|
@ -153,6 +154,15 @@ 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
|
||||
}
|
||||
|
||||
var rillMu sync.Mutex
|
||||
|
||||
// x is the size of the queued up pool (shouldn't matter here for this I think)
|
||||
// y is how many simultanous functions will run
|
||||
// todo: tune and compute x,y by # of CPUs and disk io
|
||||
|
@ -163,6 +173,9 @@ func (f *Forge) RillRepos(rillf func(*gitpb.Repo) error) map[*gitpb.Repo]error {
|
|||
var allerr map[*gitpb.Repo]error
|
||||
allerr = make(map[*gitpb.Repo]error)
|
||||
|
||||
var stats map[string]rillStats
|
||||
stats = make(map[string]rillStats)
|
||||
|
||||
for repo := range f.Repos.IterAll() {
|
||||
if !repo.IsValidDir() {
|
||||
log.Printf("%s %-50s", "got an invalid repo in forgepb.RillFuncError()", repo.GetGoPath())
|
||||
|
@ -175,7 +188,6 @@ func (f *Forge) RillRepos(rillf func(*gitpb.Repo) error) map[*gitpb.Repo]error {
|
|||
|
||||
var counter int
|
||||
var watch int = 10
|
||||
var meMu sync.Mutex
|
||||
|
||||
// Read users from the API.
|
||||
// Concurrency = 20
|
||||
|
@ -184,20 +196,33 @@ func (f *Forge) RillRepos(rillf func(*gitpb.Repo) error) map[*gitpb.Repo]error {
|
|||
})
|
||||
|
||||
rill.ForEach(dirs, f.rillY, func(repo *gitpb.Repo) error {
|
||||
meMu.Lock()
|
||||
rillMu.Lock()
|
||||
counter += 1
|
||||
if counter > watch {
|
||||
// log.Info("Processed", watch, "repos") // this doesn't work
|
||||
watch += 50
|
||||
}
|
||||
meMu.Unlock()
|
||||
rillMu.Unlock()
|
||||
if err := rillf(repo); err != nil {
|
||||
meMu.Lock()
|
||||
rillMu.Lock()
|
||||
allerr[repo] = err
|
||||
meMu.Unlock()
|
||||
rillMu.Unlock()
|
||||
rillSetError(stats, repo.GetFullPath(), err)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
return allerr
|
||||
}
|
||||
|
||||
func rillSetError(stats map[string]rillStats, fullpath string, err error) {
|
||||
rillMu.Lock()
|
||||
defer rillMu.Unlock()
|
||||
if s, ok := stats[fullpath]; ok {
|
||||
s.err = err
|
||||
return
|
||||
}
|
||||
var s rillStats
|
||||
s.err = err
|
||||
stats[fullpath] = s
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue