1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-14 11:23:02 +02:00
ferret/pkg/html/static/options.go
Tim Voronov a3d3fe727d
Bug/#31 ua (#73)
* Made custom and random UA optional

* Added pirvate context keys
2018-10-07 22:18:57 -04:00

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
}
}