Skip to content

Commit f0a8bea

Browse files
committed
rename: errors field to connErrs
This better represents what this field tracks
1 parent aacbbd9 commit f0a8bea

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

pkg/crawl/db.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (s *Scheduler) persistCrawlProperties(ctx context.Context) error {
4848
pps := map[string]map[string]int{
4949
"agent_version": avFull,
5050
"protocol": s.protocols,
51-
"error": s.errors,
51+
"error": s.connErrs,
5252
}
5353

5454
return s.dbc.PersistCrawlProperties(ctx, s.crawl, pps)

pkg/crawl/scheduler.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ type Scheduler struct {
7676
protocols map[string]int
7777

7878
// A map of errors that happened during the crawl.
79-
errors map[string]int
79+
connErrs map[string]int
8080

8181
// A map that keeps track of all k-bucket entries of a particular peer.
8282
routingTables map[peer.ID]*RoutingTable
@@ -116,7 +116,7 @@ func NewScheduler(conf *config.Crawl, dbc db.Client) (*Scheduler, error) {
116116
persistResultsQueue: queue.NewFIFO[*db.InsertVisitResult](),
117117
agentVersion: map[string]int{},
118118
protocols: map[string]int{},
119-
errors: map[string]int{},
119+
connErrs: map[string]int{},
120120
routingTables: map[peer.ID]*RoutingTable{},
121121
peerMappings: map[peer.ID]int{},
122122
}
@@ -402,7 +402,7 @@ func (s *Scheduler) handleResult(ctx context.Context, cr Result) {
402402
}
403403
} else if cr.ConnectError != nil {
404404
// Log and count connection errors
405-
s.errors[cr.ConnectErrorStr] += 1
405+
s.connErrs[cr.ConnectErrorStr] += 1
406406
if cr.ConnectErrorStr == models.NetErrorUnknown {
407407
logEntry = logEntry.WithError(cr.ConnectError)
408408
} else {
@@ -412,7 +412,6 @@ func (s *Scheduler) handleResult(ctx context.Context, cr Result) {
412412

413413
if cr.ConnectError == nil && cr.CrawlError != nil {
414414
// Log and count crawl errors
415-
s.errors[cr.CrawlErrorStr] += 1
416415
if cr.CrawlErrorStr == models.NetErrorUnknown {
417416
logEntry = logEntry.WithError(cr.CrawlError)
418417
} else {
@@ -453,7 +452,7 @@ func (s *Scheduler) logSummary() {
453452
log.Infoln("Logging crawl results...")
454453

455454
log.Infoln("")
456-
for err, count := range s.errors {
455+
for err, count := range s.connErrs {
457456
log.WithField("count", count).WithField("value", err).Infoln("Dial Error")
458457
}
459458
log.Infoln("")
@@ -477,7 +476,7 @@ func (s *Scheduler) logSummary() {
477476
// TotalErrors counts the total amount of errors - equivalent to undialable peers during this crawl.
478477
func (s *Scheduler) TotalErrors() int {
479478
sum := 0
480-
for _, count := range s.errors {
479+
for _, count := range s.connErrs {
481480
sum += count
482481
}
483482
return sum

pkg/crawl/scheduler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func TestScheduler_TotalErrors(t *testing.T) {
4040
}
4141
for _, tt := range tests {
4242
t.Run(tt.name, func(t *testing.T) {
43-
s := &Scheduler{errors: tt.errors}
43+
s := &Scheduler{connErrs: tt.errors}
4444
assert.Equal(t, tt.want, s.TotalErrors())
4545
})
4646
}

0 commit comments

Comments
 (0)