Documentation
¶
Overview ¶
Package proxy provides per-request proxy selection for CredBaron.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoHealthyProxies = errors.New("no healthy proxies available")
Functions ¶
This section is empty.
Types ¶
type FileSource ¶
type FileSource struct {
// contains filtered or unexported fields
}
FileSource loads a proxy list from disk and tracks per-entry health. A proxy reported with err != nil is considered unhealthy until `cooldown` elapses, then it is tried again.
func NewFileSource ¶
func NewFileSource(path string, s Strategy) (*FileSource, error)
type RotatingEndpointSource ¶
type RotatingEndpointSource struct {
// contains filtered or unexported fields
}
RotatingEndpointSource returns the same base proxy URL for every call but rewrites the username with a configurable session token pattern so the upstream residential-proxy provider gives each request a fresh IP.
func NewRotatingEndpoint ¶
func NewRotatingEndpoint(base *url.URL, pattern string) (*RotatingEndpointSource, error)
The pattern is appended to the username separated by "-", with tokens:
- {rand} 8-hex random per-call
- {seq} monotonic counter starting at 1
- {uuid} uuid v4
type Source ¶
type Source interface {
Next(ctx context.Context) (*url.URL, error)
// Report feeds the per-request outcome back to the source so it
// can track proxy health. err == nil means success. Implementations
// that don't track health (e.g. single rotating endpoints) make
// this a no-op.
Report(u *url.URL, err error)
}
Source hands out proxy URLs for individual HTTP requests. All implementations must be safe for concurrent use.
Click to show internal directories.
Click to hide internal directories.