Documentation
¶
Overview ¶
Package scheduler provides the periodic full-scan pipeline, DB maintenance, and auth cleanup scheduling for the subflux server.
Index ¶
- Constants
- func GuardedScan(ctx context.Context, deps *Deps)
- func PrepareFullScan(deps *Deps, source activity.ActivitySource) (actID string, run func(ctx context.Context))
- func Run(ctx context.Context, deps *Deps)
- func RunDBMaintenance(ctx context.Context, deps *Deps)
- type Deps
- type LiveState
- type ReconcileMetrics
- type Store
Constants ¶
const ( FullScanAction = "Full Scan" FullScanDetail = "Searching library for missing subtitles" )
FullScanAction and FullScanDetail are the activity strings every full library scan carries (manual and scheduled; the UI keys its last-scan timing row on the action string).
const AuthCleanupInterval = 15 * time.Minute
AuthCleanupInterval is how often expired sessions and stale auth state are purged from the database.
const OIDCStateTTL = 10 * time.Minute
OIDCStateTTL is how long an OIDC authorization flow can remain pending before garbage collection.
const StartupDelay = 30 * time.Second
StartupDelay is the delay before the first scan after startup.
Variables ¶
This section is empty.
Functions ¶
func GuardedScan ¶
GuardedScan acquires the scanning flag before running a full scan.
func PrepareFullScan ¶ added in v0.1.148
func PrepareFullScan(deps *Deps, source activity.ActivitySource) (actID string, run func(ctx context.Context))
PrepareFullScan starts the full-scan activity entry (with its structured scope and admin-only cancel role), publishes scan:start, and registers the graceful stop callback — the accept sequence, hoisted out of the scan body so the HTTP handler can return the activity id BEFORE the scan runs. The returned run func executes the scan and applies its terminal outcome; the caller owns the ScanningFlag guard and decides whether to run it inline (scheduler tick) or in a background goroutine (HTTP handler).
func RunDBMaintenance ¶
RunDBMaintenance prunes old state and stale search attempts.
Types ¶
type Deps ¶
type Deps struct {
DB api.Store
// ScanDB is the scan-state surface the full scan needs (recency set,
// stamps, cycle mark); the composition root passes the same store as DB.
ScanDB scanning.ScanStore
// Backoff feeds season-tracker earlyStop seeding; same store again.
Backoff scanning.BackoffPrefixReader
Metrics scanning.ScanMetrics
ReconcileMetrics ReconcileMetrics // nil-safe; omit to skip reconcile metrics
Events *serveradapter.ScanEventAdapter
Activity *serveradapter.ActivityAdapter
Alerts *serveradapter.AlertAdapter
// Stops registers the graceful stop callback of the running full scan;
// scheduled scans register too (stoppable by admins).
Stops *activity.StopRegistry
ShowSkipCache *showskip.Cache
StateFunc func() *LiveState
ScanningFlag *atomic.Bool
DeleteSubtitleFiles func(paths []string, source string)
}
Deps holds all dependencies for the scheduler.
type LiveState ¶
type LiveState struct {
Cfg api.ConfigProvider
Engine api.SearchEngine
Sonarr api.SonarrClient
Radarr api.RadarrClient
Providers []api.Provider
}
LiveState holds the live state needed by the scheduler.
type ReconcileMetrics ¶ added in v0.1.54
ReconcileMetrics is the narrow observability interface for reconcile passes. The concrete *metrics.Metrics satisfies this via structural typing.