mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-14 11:23:02 +02:00
a3d3fe727d
* Made custom and random UA optional * Added pirvate context keys
59 lines
976 B
Go
59 lines
976 B
Go
package static
|
|
|
|
import (
|
|
"github.com/sethgrid/pester"
|
|
)
|
|
|
|
type (
|
|
Option func(opts *Options)
|
|
Options struct {
|
|
backoff pester.BackoffStrategy
|
|
maxRetries int
|
|
concurrency int
|
|
proxy string
|
|
userAgent string
|
|
}
|
|
)
|
|
|
|
func WithDefaultBackoff() Option {
|
|
return func(opts *Options) {
|
|
opts.backoff = pester.DefaultBackoff
|
|
}
|
|
}
|
|
|
|
func WithLinearBackoff() Option {
|
|
return func(opts *Options) {
|
|
opts.backoff = pester.LinearBackoff
|
|
}
|
|
}
|
|
|
|
func WithExponentialBackoff() Option {
|
|
return func(opts *Options) {
|
|
opts.backoff = pester.ExponentialBackoff
|
|
}
|
|
}
|
|
|
|
func WithMaxRetries(value int) Option {
|
|
return func(opts *Options) {
|
|
opts.maxRetries = value
|
|
}
|
|
}
|
|
|
|
func WithConcurrency(value int) Option {
|
|
return func(opts *Options) {
|
|
opts.concurrency = value
|
|
}
|
|
}
|
|
|
|
func WithProxy(address string) Option {
|
|
return func(opts *Options) {
|
|
opts.proxy = address
|
|
}
|
|
}
|
|
|
|
func WithUserAgent(value string) Option {
|
|
return func(opts *Options) {
|
|
opts.userAgent = value
|
|
}
|
|
}
|