diff options
Diffstat (limited to 'reports.go')
| -rw-r--r-- | reports.go | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -3,8 +3,31 @@ package lilin +import "sync" + +const failKeepSize = 600 +const failMax = failKeepSize + (failKeepSize / 3) + // Reports contains the report for all services. type Reports struct { Services map[string]*ServiceReport Title string + Fail []ScanReport + sync.Mutex +} + +// Store the service scan report. +func (reports *Reports) Store(scanReport ScanReport) { + reports.Lock() + var svcReport = reports.Services[scanReport.Name] + svcReport.Store(scanReport) + if !scanReport.Success { + reports.Fail = append(reports.Fail, scanReport) + if len(reports.Fail) >= failMax { + var start = len(reports.Fail) - failKeepSize + copy(reports.Fail, reports.Fail[start:]) + reports.Fail = reports.Fail[:failKeepSize-1] + } + } + reports.Unlock() } |
