proxypool

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package proxypool provides concurrent iteration over proxies stored one per line in a text file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mode

type Mode uint8

Mode specifies the iteration order used by a ProxyPool.

const (
	// ModeSequential makes [ProxyPool.Next] return proxies in file order.
	// It streams the file without constructing a sidecar index.
	ModeSequential Mode = iota

	// ModeShuffled makes [ProxyPool.Next] return each proxy once per cycle in a
	// permutation selected by [New].
	ModeShuffled
)

func (Mode) IsValid added in v0.3.0

func (m Mode) IsValid() bool

IsValid reports whether m is a supported Mode.

func (Mode) Valid added in v0.3.0

func (m Mode) Valid() error

Valid returns an error when m is not a supported Mode.

type ProxyPool

type ProxyPool interface {
	// Close releases resources held by the pool.
	// Calls after the first return nil.
	Close() error

	// Next returns the next proxy.
	// It reports false when the pool is closed, empty, or exhausted.
	Next() (string, bool)

	// NextBytes appends the next proxy to dst[:0] and returns the resulting slice.
	// It reports false when the pool is closed, empty, or exhausted.
	//
	// If dst has sufficient capacity, the returned slice aliases dst and the
	// call performs no allocation.
	NextBytes(dst []byte) ([]byte, bool)
}

ProxyPool provides read-only iteration over proxies stored in a file. A ProxyPool is safe for concurrent use by multiple goroutines.

func New

func New(path string, mode Mode, reuse bool) (ProxyPool, error)

New opens path and returns a ProxyPool that reads one proxy per line.

Mode determines iteration order. If reuse is true, iteration begins another cycle after the final proxy. Otherwise, the pool remains exhausted.

ModeShuffled builds or reads a path+".idx" sidecar containing file offsets. [ProxyPool.Close] removes that sidecar.

Jump to

Keyboard shortcuts

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