Skip to content

Commit

Permalink
fix: move sleep to proper place
Browse files Browse the repository at this point in the history
  • Loading branch information
kris-dev-hub committed Jan 3, 2024
1 parent e52f84e commit db580c7
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions cmd/importer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"bufio"
"fmt"
"github.com/kris-dev-hub/globallinks/pkg/healthcheck"

Check failure on line 6 in cmd/importer/main.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)
"log"
"net/http"
"os"
Expand All @@ -14,8 +15,6 @@ import (
"sync"
"time"

Check failure on line 16 in cmd/importer/main.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)

Check failure on line 17 in cmd/importer/main.go

View workflow job for this annotation

GitHub Actions / lint

File is not `goimports`-ed (goimports)
"github.com/kris-dev-hub/globallinks/pkg/healthcheck"

"github.com/klauspost/compress/gzip"

"github.com/kris-dev-hub/globallinks/pkg/commoncrawl"
Expand Down Expand Up @@ -204,11 +203,6 @@ func importSegment(segment commoncrawl.WatSegment, dataDir commoncrawl.DataDir,

for _, watFile := range segment.WatFiles {

// sleep between WAT files to avoid common crawl transfer limitation
if sleepBetweenWat > 0 {
time.Sleep(time.Duration(sleepBetweenWat) * time.Second)
}

// ignore imported files
if watFile.Imported != nil {
continue
Expand Down Expand Up @@ -254,6 +248,11 @@ func importSegment(segment commoncrawl.WatSegment, dataDir commoncrawl.DataDir,
panic(fmt.Sprintf("Failed to create file: %v", err))
}

// sleep between WAT files to avoid common crawl transfer limitation
if sleepBetweenWat > 0 {
time.Sleep(time.Duration(sleepBetweenWat) * time.Second)
}

wg.Add(1)
// Before starting the goroutine, we insert an empty struct into the guard channel.
// If the channel is already full (meaning we have 'maxGoroutines' goroutines running),
Expand Down

0 comments on commit db580c7

Please sign in to comment.