Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ On merge, CI will:

## [Unreleased]

_Add unreleased changes here._
### Changed

- Crawler user agent is now always exactly `config.UserAgent`. Dropped the dead
`Worker-<id>` suffix branch in `crawler.New` along with the unused variadic ID
parameter and struct field.

## Full changelog history

Expand Down
16 changes: 2 additions & 14 deletions internal/crawler/crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ func buildRequestAttemptDiagnostics(
type Crawler struct {
config *Config
colly *colly.Collector
id string
metricsMap *sync.Map
aia *aiaTransport
probeClient *http.Client // Shared to avoid per-call transport leaks.
Expand Down Expand Up @@ -291,23 +290,13 @@ func (t *tracingRoundTripper) RoundTrip(req *http.Request) (*http.Response, erro
return t.transport.RoundTrip(req)
}

func New(config *Config, id ...string) *Crawler {
func New(config *Config) *Crawler {
if config == nil {
config = DefaultConfig()
}

crawlerID := ""
if len(id) > 0 {
crawlerID = id[0]
}

userAgent := config.UserAgent
if crawlerID != "" {
userAgent = fmt.Sprintf("%s Worker-%s", config.UserAgent, crawlerID)
}

c := colly.NewCollector(
colly.UserAgent(userAgent),
colly.UserAgent(config.UserAgent),
colly.MaxDepth(1),
colly.Async(true),
colly.AllowURLRevisit(),
Expand Down Expand Up @@ -373,7 +362,6 @@ func New(config *Config, id ...string) *Crawler {
return &Crawler{
config: config,
colly: c,
id: crawlerID,
metricsMap: metricsMap,
aia: aiaRT,
probeClient: &http.Client{
Expand Down
Loading