mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-16 11:37:36 +02:00
5620be211c
* Renamed DOCUMENT to PAGE * Added PageLoadParams * Added PageLoadParams * Renamed LoadPageParams -> PageLoadParams * Added support for context.Done() (#201) * Bug/#189 operators precedence (#202) * Fixed math operators precedence * Fixed logical operators precedence * Fixed array operator * Added support for parentheses to enforce a different operator evaluation order * Feature/#200 drivers (#209) * Added new interfaces * Renamed dynamic to cdp driver * Renamed drivers * Added ELEMENT_EXISTS function (#210) * Renamed back PAGE to DOCUMENT (#211) * Added Getter and Setter interfaces
73 lines
1.2 KiB
Go
73 lines
1.2 KiB
Go
package http
|
|
|
|
import (
|
|
"github.com/sethgrid/pester"
|
|
)
|
|
|
|
type (
|
|
Option func(opts *Options)
|
|
|
|
Options struct {
|
|
backoff pester.BackoffStrategy
|
|
maxRetries int
|
|
concurrency int
|
|
proxy string
|
|
userAgent string
|
|
}
|
|
)
|
|
|
|
func newOptions(setters []Option) *Options {
|
|
opts := new(Options)
|
|
opts.backoff = pester.ExponentialBackoff
|
|
opts.concurrency = 3
|
|
opts.maxRetries = 5
|
|
|
|
for _, setter := range setters {
|
|
setter(opts)
|
|
}
|
|
|
|
return opts
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|