engine

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine orchestrates the dispatch loop.

func New

func New(cfg *config.Config, m *metrics.Metrics) (*Engine, error)

New creates an Engine wired with all dependencies.

func (*Engine) Reload added in v0.4.0

func (e *Engine) Reload(newCfg *config.Config) error

Reload atomically applies a new configuration to the running engine. Targets, rate limits, backoff, and pacing are updated in-place. Changes to pacing mode, resource limits, or scheduled windows require a restart.

func (*Engine) Run

func (e *Engine) Run(ctx context.Context)

Run starts the engine and blocks until ctx is cancelled. After ctx is cancelled it waits for all in-flight tasks to complete.

func (*Engine) SetObserver added in v1.0.0

func (e *Engine) SetObserver(fn func(task.Result))

SetObserver registers a function called after every completed dispatch. It is safe to call before or after Run. Pass nil to clear.

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool manages a global concurrency semaphore and an optional browser sub-semaphore.

func NewPool

func NewPool(maxWorkers, maxBrowserWorkers int) *Pool

NewPool creates a Pool with the given global and browser worker limits.

func (*Pool) Acquire

func (p *Pool) Acquire(ctx context.Context, taskType string) error

Acquire obtains a global slot (and a browser slot for browser tasks). Blocks until slots are available or ctx is cancelled.

func (*Pool) Release

func (p *Pool) Release(taskType string)

Release frees the slots acquired for the given task type.

func (*Pool) Wait

func (p *Pool) Wait()

Wait blocks until all in-flight tasks have completed.

type Scheduler

type Scheduler struct {
	// contains filtered or unexported fields
}

Scheduler controls inter-request timing based on the configured pacing mode.

func NewScheduler

func NewScheduler(cfg config.PacingConfig) *Scheduler

NewScheduler creates a Scheduler from the pacing config.

func (*Scheduler) Start

func (s *Scheduler) Start(ctx context.Context)

Start launches background goroutines needed by the scheduler (cron for scheduled mode).

func (*Scheduler) UpdatePacing added in v0.4.0

func (s *Scheduler) UpdatePacing(cfg config.PacingConfig)

UpdatePacing updates reloadable pacing parameters at runtime. Mode changes are not supported — callers should warn and skip.

func (*Scheduler) Wait

func (s *Scheduler) Wait(ctx context.Context) error

Wait implements the pacing delay for the current mode. It blocks until it is appropriate to dispatch the next request.

Jump to

Keyboard shortcuts

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