stallwatcher

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package stallwatcher is the Pilot-side consumer of Haul's stall detection.

Every 60 seconds it polls Haul's /api/v1/stalls endpoint, correlates each stalled torrent with a grab_history row (via info_hash), writes a blocklist entry for the release (reason tagged with the stall type), and marks the grab as stalled. If the grab was triggered by auto-search, the watcher also triggers a re-search for the episode, capped by a circuit breaker to avoid loops when every release for an episode is dead.

It pulls rather than receiving webhooks, and tolerates Haul being briefly unreachable. It does not blocklist during its own first two minutes: after a restart, grabs from before it can look stalled only because they haven't been observed yet.

Index

Constants

View Source
const MaxStallRetriesPerEpisode = 3

MaxStallRetriesPerEpisode is the circuit breaker: after this many stall-reason blocklist entries for a (series, episode) in the last 24 hours, auto-re-search stops. Prevents infinite loops when every release for an episode happens to be dead.

View Source
const StaleGrabAge = 24 * time.Hour

StaleGrabAge is how long a grab can sit in `downloading` / `queued` / `pending` without an info_hash before the sweep marks it failed. The info_hash-less branch is invisible to the haul-stall path (haul keys stalls by info_hash), so the only signal we have is age. 24h is well past any normal "metadata fetch + tracker announce + first peer" startup, and it leaves a generous window for genuinely-slow first connects on remote VPN endpoints.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service polls Haul for stalled torrents and reacts by blocklisting the corresponding release.

func NewService

func NewService(
	q db.Querier,
	blocklist *blocklist.Service,
	downloader *downloader.Service,
	bus *events.Bus,
	logger *slog.Logger,
) *Service

NewService constructs a stallwatcher Service. Call Run in a goroutine.

func (*Service) Run

func (s *Service) Run(ctx context.Context)

Run is a blocking poll loop. Returns when ctx is canceled.

func (*Service) Tick

func (s *Service) Tick(ctx context.Context) error

Tick runs one poll cycle. Exposed for tests and manual invocation.

Jump to

Keyboard shortcuts

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