1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-03-05 15:16:07 +02:00
ferret/pkg/html/static/options.go

59 lines
976 B
Go
Raw Normal View History

2018-09-26 22:03:06 -04:00
package static
2018-09-18 16:42:38 -04:00
import (
"github.com/sethgrid/pester"
)
2018-09-18 16:42:38 -04:00
type (
Option func(opts *Options)
Options struct {
backoff pester.BackoffStrategy
maxRetries int
concurrency int
proxy string
userAgent string
}
2018-09-18 16:42:38 -04:00
)
func WithDefaultBackoff() Option {
return func(opts *Options) {
opts.backoff = pester.DefaultBackoff
2018-09-18 16:42:38 -04:00
}
}
func WithLinearBackoff() Option {
return func(opts *Options) {
opts.backoff = pester.LinearBackoff
2018-09-18 16:42:38 -04:00
}
}
func WithExponentialBackoff() Option {
return func(opts *Options) {
opts.backoff = pester.ExponentialBackoff
2018-09-18 16:42:38 -04:00
}
}
func WithMaxRetries(value int) Option {
return func(opts *Options) {
opts.maxRetries = value
2018-09-18 16:42:38 -04:00
}
}
func WithConcurrency(value int) Option {
return func(opts *Options) {
opts.concurrency = value
}
}
func WithProxy(address string) Option {
return func(opts *Options) {
opts.proxy = address
2018-09-18 16:42:38 -04:00
}
}
func WithUserAgent(value string) Option {
return func(opts *Options) {
opts.userAgent = value
}
}