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
- type StatsStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deps ¶
type Deps struct {
QueryDB QueryStore
CovDB StatsStore
Metrics MetricsReader
State func() *LiveState
Configured func() bool
// CountMissing counts missing subtitle targets. It is handed to this package
// ALREADY BOUND to the store: the count reads subtitle-file rows, this
// package never does, and taking the store as a parameter just to forward it
// is what made these handlers look like a store consumer twelve methods
// wide. cfg stays a parameter because it is hot-reloadable and arrives with
// each request's live snapshot — 2 of the 37 values the config offers, named
// from coverage for the same reason the store half named FileReader there:
// the contract belongs to the function, and re-listing it here is how the
// two halves of one signature drift apart.
CountMissing func(ctx context.Context, cfg coverage.CountCfg, 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 handles GET /api/backoff.
func (*Handler) HandleBackoffByPrefix ¶
func (h *Handler) HandleBackoffByPrefix(w http.ResponseWriter, r *http.Request)
HandleBackoffByPrefix handles GET /api/backoff/prefix?type=episode&prefix=tvdb-81189-.
func (*Handler) HandleConfigParsed ¶
func (h *Handler) HandleConfigParsed(w http.ResponseWriter, r *http.Request)
HandleConfigParsed handles GET /api/config/parsed.
func (*Handler) HandleLocks ¶
func (h *Handler) HandleLocks(w http.ResponseWriter, r *http.Request)
HandleLocks handles GET /api/locks.
func (*Handler) HandleProviderTimeout ¶
func (h *Handler) HandleProviderTimeout(w http.ResponseWriter, r *http.Request)
HandleProviderTimeout handles GET /api/providers/timeout.
func (*Handler) HandleProviderTimeoutReset ¶
func (h *Handler) HandleProviderTimeoutReset(w http.ResponseWriter, r *http.Request)
HandleProviderTimeoutReset handles POST /api/providers/timeout/reset.
func (*Handler) HandleProviders ¶
func (h *Handler) HandleProviders(w http.ResponseWriter, r *http.Request)
HandleProviders handles GET /api/providers.
func (*Handler) HandleScore ¶
func (h *Handler) HandleScore(w http.ResponseWriter, r *http.Request)
HandleScore handles POST /api/score (JSON body).
func (*Handler) HandleSearchTargets ¶
func (h *Handler) HandleSearchTargets(w http.ResponseWriter, r *http.Request)
HandleSearchTargets handles GET /api/search/targets?orig_lang=en&audio_langs=en,fr: resolves subtitle targets for a media item without actually searching.
func (*Handler) HandleState ¶
func (h *Handler) HandleState(w http.ResponseWriter, r *http.Request)
HandleState handles 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 handles 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 queryCfg
Engine queryEngine
Sonarr StatsSonarrClient
Radarr StatsRadarrClient
Providers []provider.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 subflux.LanguageRulesJSON `json:"language_rules"`
IgnoredCodecs []string `json:"ignored_codecs,omitempty"`
Languages []string `json:"languages"`
Scores subflux.Scores `json:"scores"`
PostProcessing subflux.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 {
State(ctx context.Context, q *subflux.StateQuery) ([]subflux.StateEntry, error)
BackoffItems(ctx context.Context) ([]subflux.BackoffEntry, error)
BackoffByPrefix(ctx context.Context, mediaType subflux.MediaType, mediaIDPrefix string) ([]subflux.BackoffEntry, error)
ManualLocks(ctx context.Context) ([]subflux.ManualLockEntry, error)
Stats(ctx context.Context) (downloads, attempts int, err error)
}
QueryStore is the read-only introspection surface behind /api/state, /api/backoff and /api/locks: 5 of the 36 methods the store offers, all of them reads. Nothing on this path writes, which is why no write appears here.
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.
type StatsSonarrClient ¶ added in v0.1.106
StatsSonarrClient is the Sonarr surface the stats handler uses.
type StatsStore ¶ added in v0.4.0
type StatsStore interface {
TotalSubtitleFiles(ctx context.Context) (int, error)
LastScanTime(ctx context.Context) (string, error)
}
StatsStore is the two aggregate reads the stats endpoint reports: how many subtitle files are tracked, and when the last scan finished. 2 of the twelve methods the coverage surface offers — /api/state/stats renders a summary, so it never touches a per-item row.