summaryrefslogtreecommitdiff
path: root/rill.go
diff options
context:
space:
mode:
Diffstat (limited to 'rill.go')
-rw-r--r--rill.go37
1 files changed, 31 insertions, 6 deletions
diff --git a/rill.go b/rill.go
index 9289d6d..2987d82 100644
--- a/rill.go
+++ b/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
+}