Documentation
¶
Overview ¶
Package queryhandlers provides read-only HTTP query handlers: subtitle state, backoff, manual locks, providers, parsed config, score simulation, and dashboard stats.
Index ¶
- type Deps
- type Handler
- func (h *Handler) HandleBackoff(w http.ResponseWriter, r *http.Request)
- func (h *Handler) HandleBackoffByPrefix(w http.ResponseWriter, r *http.Request)
- func (h *Handler) HandleConfigParsed(w http.ResponseWriter, r *http.Request)
- func (h *Handler) HandleLocks(w http.ResponseWriter, r *http.Request)
- func (h *Handler) HandleProviderTimeout(w http.ResponseWriter, r *http.Request)
- func (h *Handler) HandleProviderTimeoutReset(w http.ResponseWriter, r *http.Request)
- func (h *Handler) HandleProviders(w http.ResponseWriter, r *http.Request)
- func (h *Handler) HandleScore(w http.ResponseWriter, r *http.Request)
- func (h *Handler) HandleSearchTargets(w http.ResponseWriter, r *http.Request)
- func (h *Handler) HandleState(w http.ResponseWriter, r *http.Request)
- func (h *Handler) HandleStateStats(w http.ResponseWriter, r *http.Request)
- func (h *Handler) InvalidateStats()
- func (h *Handler) StatsInvalidator() StatsCacheInvalidator
- type LiveState
- type MetricsReader
- type ParsedConfig
- type ProviderInfo
- type QueryStore
- type StatsCacheInvalidator
- type StatsRadarrClient
- type StatsSonarrClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deps ¶
type Deps struct {
QueryDB QueryStore
CovDB api.CoverageStore
Metrics MetricsReader
State func() *LiveState
Configured func() bool
CountMissing func(ctx context.Context, cfg api.ConfigProvider, db api.CoverageStore, series []arrapi.Series, movies []arrapi.Movie) int
}
Deps holds all dependencies for the query handler family.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler holds all dependencies for the query handler family.
func (*Handler) HandleBackoff ¶
func (h *Handler) HandleBackoff(w http.ResponseWriter, r *http.Request)
HandleBackoff returns items currently in adaptive search backoff. GET /api/backoff
func (*Handler) HandleBackoffByPrefix ¶
func (h *Handler) HandleBackoffByPrefix(w http.ResponseWriter, r *http.Request)
HandleBackoffByPrefix returns backoff entries for media IDs matching a prefix. GET /api/backoff/prefix?type=episode&prefix=tvdb-81189-
func (*Handler) HandleConfigParsed ¶
func (h *Handler) HandleConfigParsed(w http.ResponseWriter, r *http.Request)
HandleConfigParsed returns the config as structured JSON. GET /api/config/parsed
func (*Handler) HandleLocks ¶
func (h *Handler) HandleLocks(w http.ResponseWriter, r *http.Request)
HandleLocks returns all manually locked media+language pairs. GET /api/locks
func (*Handler) HandleProviderTimeout ¶
func (h *Handler) HandleProviderTimeout(w http.ResponseWriter, r *http.Request)
HandleProviderTimeout returns provider timeout state for all providers. GET /api/providers/timeout
func (*Handler) HandleProviderTimeoutReset ¶
func (h *Handler) HandleProviderTimeoutReset(w http.ResponseWriter, r *http.Request)
HandleProviderTimeoutReset clears all provider timeout state and re-enables all providers. POST /api/providers/timeout/reset
func (*Handler) HandleProviders ¶
func (h *Handler) HandleProviders(w http.ResponseWriter, r *http.Request)
HandleProviders returns registered providers with enabled status. GET /api/providers
func (*Handler) HandleScore ¶
func (h *Handler) HandleScore(w http.ResponseWriter, r *http.Request)
HandleScore simulates scoring a subtitle against a video. POST /api/score with JSON body.
func (*Handler) HandleSearchTargets ¶
func (h *Handler) HandleSearchTargets(w http.ResponseWriter, r *http.Request)
HandleSearchTargets resolves subtitle targets for a media item without actually searching. Useful for debugging language rules. GET /api/search/targets?orig_lang=en&audio_langs=en,fr
func (*Handler) HandleState ¶
func (h *Handler) HandleState(w http.ResponseWriter, r *http.Request)
HandleState returns subtitle state with optional filters. GET /api/state?type=episode&lang=fr&provider=opensubtitles&limit=50
func (*Handler) HandleStateStats ¶
func (h *Handler) HandleStateStats(w http.ResponseWriter, r *http.Request)
HandleStateStats returns aggregate stats for the dashboard. GET /api/state/stats
func (*Handler) InvalidateStats ¶
func (h *Handler) InvalidateStats()
InvalidateStats marks the stats cache stale.
func (*Handler) StatsInvalidator ¶
func (h *Handler) StatsInvalidator() StatsCacheInvalidator
StatsInvalidator returns the statsCache as a StatsCacheInvalidator for use by the polling subsystem.
type LiveState ¶
type LiveState struct {
Cfg api.ConfigProvider
Engine api.SearchEngine
Sonarr StatsSonarrClient
Radarr StatsRadarrClient
Providers []api.Provider
}
LiveState holds the hot-reloadable runtime state needed by query handlers.
type MetricsReader ¶
type MetricsReader interface {
TotalSearches() int64
}
MetricsReader is the narrow interface for reading search metrics.
type ParsedConfig ¶ added in v0.1.148
type ParsedConfig struct {
Adaptive any `json:"adaptive"`
Search any `json:"search"`
Providers map[string]bool `json:"providers"`
SonarrURL string `json:"sonarr_url,omitempty"`
RadarrURL string `json:"radarr_url,omitempty"`
LanguageRules api.LanguageRulesJSON `json:"language_rules"`
IgnoredCodecs []string `json:"ignored_codecs,omitempty"`
Languages []string `json:"languages"`
Scores api.Scores `json:"scores"`
PostProcessing api.PostProcessConfig `json:"post_processing"`
Configured bool `json:"configured"`
Sonarr bool `json:"sonarr_configured"`
Radarr bool `json:"radarr_configured"`
}
ParsedConfig is the GET /api/config/parsed response: the live parsed configuration in UI-consumable form. Adaptive and Search carry the config package's structs verbatim (their Go field names are the wire keys); they are typed loosely here to keep this package decoupled from the config internals.
type ProviderInfo ¶ added in v0.1.148
type ProviderInfo struct {
Name string `json:"name"`
Enabled bool `json:"enabled"`
Loaded bool `json:"loaded"`
}
ProviderInfo is one entry of the GET /api/providers response: a registered provider's config-enabled flag and whether it is currently loaded.
type QueryStore ¶
type QueryStore interface {
GetState(ctx context.Context, q *api.StateQuery) ([]api.StateEntry, error)
GetBackoffItems(ctx context.Context) ([]api.BackoffEntry, error)
GetBackoffByPrefix(ctx context.Context, mediaType api.MediaType, mediaIDPrefix string) ([]api.BackoffEntry, error)
GetManualLocks(ctx context.Context) ([]api.ManualLockEntry, error)
Stats(ctx context.Context) (downloads, attempts int, err error)
}
QueryStore documents the api.Store methods used by query handlers.
type StatsCacheInvalidator ¶
type StatsCacheInvalidator interface {
Invalidate()
}
StatsCacheInvalidator is the narrow interface for stats cache invalidation.
type StatsRadarrClient ¶ added in v0.1.106
StatsRadarrClient is the Radarr surface the stats handler uses.