tweetfinder

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoTops              = errors.New("no top tweets")
	ErrNotFound            = errors.New("not found")
	ErrTimeoutSelectFinder = errors.New("timeout select finder")
)

Functions

This section is empty.

Types

type ConfigProxies added in v0.0.20

type ConfigProxies struct {
	Port      string   `envconfig:"PROXY_PORT"`
	Addresses []string `envconfig:"PROXY_ADDRESSES"`
	Username  string   `envconfig:"PROXY_USERNAME"`
	Password  string   `envconfig:"PROXY_PASSWORD"`
}

func GetConfigPool

func GetConfigPool() ConfigProxies

func (ConfigProxies) GetProxies added in v0.0.20

func (c ConfigProxies) GetProxies() []string

type Finder

type Finder interface {
	IsHot() bool
	FindNext(ctx context.Context, start, end *time.Time, search, cursor string) ([]common.TweetSnapshot, string, error)
	Find(ctx context.Context, id string) (*common.TweetSnapshot, error)
	CurrentDelay() int64
	CurrentTemp(ctx context.Context) float64
	Init(ctx context.Context) error
}

func NewFinder

func NewFinder(scraper *twitterscraper.Scraper, delayManager delayManager, logger log.Logger) Finder

func NewMetricMiddleware

func NewMetricMiddleware(one, nextHist *prometheus.HistogramVec, login string, next Finder) Finder

func NewPool

func NewPool(metricsOne, metricsNext *prometheus.HistogramVec, metricsDelay *prometheus.GaugeVec,
	config ConfigProxies, manager accountManager, db repo, logger log.Logger) Finder

type Manager

type Manager interface {
	TooManyRequests(ctx context.Context)
	AfterRequest()
	CurrentDelay() int64
	CurrentTemp(ctx context.Context) float64
	Start(ctx context.Context) error
}

func NewDelayManagerV2

func NewDelayManagerV2(
	setter func(seconds int64),
	windowLimiters []WindowLimiter,
	minimalDelay int64,
	log log.Logger,
) Manager

type WindowLimiter

type WindowLimiter interface {
	Inc()
	TrySetThreshold(ctx context.Context, startTime time.Time) error
	Duration() time.Duration
	RecommendedDelay(ctx context.Context) (uint64, error)
	SetResetLimiter(resetLimiter windowlimiter.ResetLimiter)
	Threshold(ctx context.Context) uint64
	Temp(ctx context.Context) float64
	Start(ctx context.Context, delay int64) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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