proxybroker

package
v0.0.0-...-3956a85 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PriorityQueue

type PriorityQueue []*Proxy

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i, j int)

func (*PriorityQueue) Update

func (pq *PriorityQueue) Update(item *Proxy, priority int)

type Proxy

type Proxy struct {
	Name            string
	Client          *http.Client
	Times           []time.Duration
	LimitsPerDomain map[string]*rate.Limit

	IsReady bool
	// contains filtered or unexported fields
}

func NewProxy

func NewProxy(proxy string) *Proxy

func ProxyTester

func ProxyTester(proxy string) *Proxy

func (*Proxy) Do

func (proxy *Proxy) Do(req *http.Request) []byte

func (*Proxy) MeanTime

func (proxy *Proxy) MeanTime() time.Duration

MeanTime returns the mean time it took the last 10 requests

type ProxyBroker

type ProxyBroker struct {
	// Proxies
	PriorityQueue PriorityQueue
	ProxyExist    map[string]bool

	// Config
	SourceFn                   func() []string
	ProxyTesterFn              func(string) *Proxy
	LimitsPerDomain            map[string]*rate.Limit
	DurationBetweenSourceFetch time.Duration
	NumberOfParallelTest       int
	// contains filtered or unexported fields
}

func NewDefault

func NewDefault() *ProxyBroker

func (*ProxyBroker) Do

func (pb *ProxyBroker) Do(req *http.Request) (result []byte)

func (*ProxyBroker) Init

func (pb *ProxyBroker) Init(waitN int) *ProxyBroker

func (*ProxyBroker) WithDomainRateLimit

func (pb *ProxyBroker) WithDomainRateLimit(domain string, limit *rate.Limit) *ProxyBroker

func (*ProxyBroker) WithSourceFn

func (pb *ProxyBroker) WithSourceFn(sourceFn func() []string) *ProxyBroker

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL