scheduler

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotifyIndexerStarted  func(librarySlug string, libraryName string)
	NotifyIndexerProgress func(librarySlug string, currentMedia string, progress string)
	NotifyIndexerFinished func(librarySlug string)
	NotifyScraperStarted  func(scriptID int64, scriptName string)
	NotifyScraperFinished func(scriptID int64)
)

Callback functions for job status notifications (set by handlers package)

View Source
var (
	DataDirectory = ""

	IndexMediaFunc func(path, librarySlug string, dataBackend filestore.DataBackend) (string, error)
)

Functions

func BroadcastLog

func BroadcastLog(key string, logType string, message string)

BroadcastLog sends a log message to all connected clients for a key

func CancelScriptExecution

func CancelScriptExecution(scriptID int64) error

CancelScriptExecution cancels a running script by ID

func ContainsEPUBFiles

func ContainsEPUBFiles(dirPath string) bool

ContainsEPUBFiles checks if a directory contains any .epub files

func DetectWebtoonFromImages

func DetectWebtoonFromImages(mangaPath, slug string) string

DetectWebtoonFromImages attempts to detect if a media is a webtoon by checking the aspect ratio of the middle image in the first chapter. Returns "webtoon" if detected, or empty string if not detected or on error.

func DownloadAndStoreImage added in v1.8.0

func DownloadAndStoreImage(slug, coverArtURL string) (string, error)

func HandleLocalImages

func HandleLocalImages(slug, absolutePath string) (string, error)

func HandleLogsWebSocket

func HandleLogsWebSocket(c *websocket.Conn, key string)

HandleLogsWebSocket establishes a WebSocket connection for streaming logs

func IndexChapters

func IndexChapters(slug, path, librarySlug string, dryRun bool) (int, int, []string, int, error)

IndexChapters reconciles chapter files on disk with the stored chapter records. Returns added count, deleted count, new chapter slugs, and total file count. If dryRun is true, only counts files without performing database operations.

func IndexMedia

func IndexMedia(absolutePath, librarySlug string, dataBackend filestore.DataBackend) (string, error)

IndexMedia inspects a media directory or file (.cbz/.cbr), syncing metadata and chapters with the database.

func InitializeIndexer

func InitializeIndexer(dataDirectory string, libraries []models.Library, cb filestore.DataBackend)

InitializeIndexer sets up indexers and notifications

func InitializeScraperScheduler

func InitializeScraperScheduler()

InitializeScraperScheduler initializes the scraper scheduler

func InitializeSubscriptionScheduler added in v1.9.0

func InitializeSubscriptionScheduler()

InitializeSubscriptionScheduler initializes the subscription expiry scheduler

func RegisterScraperScript

func RegisterScraperScript(script *models.ScraperScript) error

RegisterScraperScript registers a single scraper script with the scheduler

func ReloadScraperScheduler

func ReloadScraperScheduler()

ReloadScraperScheduler reloads the scraper scheduler

func ReloadSubscriptionScheduler added in v1.9.0

func ReloadSubscriptionScheduler()

ReloadSubscriptionScheduler reloads the subscription scheduler

func StartScriptExecution

func StartScriptExecution(script *models.ScraperScript, variables map[string]string, createLog bool) (*models.ScraperExecutionLog, error)

StartScriptExecution begins executing a script and streams logs. If createLog is true, an execution log will be created in the DB and returned. Returns error if the script is already running.

func StopAllIndexers

func StopAllIndexers()

StopAllIndexers stops all running indexers

func StopScraperScheduler

func StopScraperScheduler()

StopScraperScheduler stops the scraper scheduler

func StopSubscriptionScheduler added in v1.9.0

func StopSubscriptionScheduler()

StopSubscriptionScheduler stops the subscription scheduler

Types

type ContentType

type ContentType int
const (
	MediaDirectory ContentType = iota
	LightnovelDirectory
	SingleMediaFile
	SingleLightNovelFile
	Skip
)

type CronScheduler

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

CronScheduler manages cron jobs

func NewCronScheduler

func NewCronScheduler() *CronScheduler

NewCronScheduler creates a new cron scheduler

func (*CronScheduler) AddJob

func (s *CronScheduler) AddJob(name string, schedule string, job Job) error

AddJob adds a job with the given schedule

func (*CronScheduler) IsRunning

func (s *CronScheduler) IsRunning() bool

IsRunning returns whether the scheduler is running

func (*CronScheduler) Reload

func (s *CronScheduler) Reload()

Reload stops and restarts the scheduler (useful for reloading jobs)

func (*CronScheduler) RemoveJob

func (s *CronScheduler) RemoveJob(name string)

RemoveJob removes a job by name

func (*CronScheduler) Start

func (s *CronScheduler) Start()

Start starts the scheduler

func (*CronScheduler) Stop

func (s *CronScheduler) Stop()

Stop stops the scheduler

type EPUBMetadata

type EPUBMetadata struct {
	Author        string
	Description   string
	Year          int
	Language      string
	Status        string
	ContentRating string
	CoverArtURL   string
	Tags          []string
}

type Indexer

type Indexer struct {
	Library          models.Library
	Scheduler        *CronScheduler
	SchedulerRunning bool
	JobRunning       bool
	// contains filtered or unexported fields
}

Indexer represents the state of an indexer

func NewIndexer

func NewIndexer(library models.Library) *Indexer

NewIndexer creates a new Indexer instance

func (*Indexer) RunIndexingJob

func (idx *Indexer) RunIndexingJob() bool

RunIndexingJob triggers the indexer job immediately

func (*Indexer) Start

func (idx *Indexer) Start()

Start initializes and starts the Indexer

func (*Indexer) Stop

func (idx *Indexer) Stop()

type IndexingExecuteFunc

type IndexingExecuteFunc func(library *models.Library) error

IndexingExecuteFunc is the function signature for executing indexing

type IndexingJob

type IndexingJob struct {
	Library     *models.Library
	ExecuteFunc IndexingExecuteFunc
}

IndexingJob represents an indexing job for a library

func (*IndexingJob) Execute

func (j *IndexingJob) Execute() error

Execute runs the indexing for the library

func (*IndexingJob) Name

func (j *IndexingJob) Name() string

Name returns the job name

type Job

type Job interface {
	Execute() error
	Name() string
}

Job represents a scheduled job that can be executed

type LogStreamManager

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

LogStreamManager manages WebSocket connections for log streaming

type NotificationListener

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

cleanupOrphanedDuplicates removes duplicate entries where one or both folders no longer exist on disk NotificationListener listens for notifications and handles them

func (*NotificationListener) Notify

func (nl *NotificationListener) Notify(notification models.Notification)

Notify processes incoming notifications

type OPF

type OPF struct {
	Metadata struct {
		Meta []struct {
			Name    string `xml:"name,attr"`
			Content string `xml:"content,attr"`
		} `xml:"meta"`
		Subject []string `xml:"dc:subject"`
	} `xml:"metadata"`
	Manifest struct {
		Item []struct {
			ID         string `xml:"id,attr"`
			Href       string `xml:"href,attr"`
			Properties string `xml:"properties,attr"`
		} `xml:"item"`
	} `xml:"manifest"`
}

OPF represents the structure of an EPUB's OPF file

type ScraperExecuteFunc

type ScraperExecuteFunc func(script *models.ScraperScript) error

ScraperExecuteFunc is the function signature for executing a scraper script

type ScraperJob

type ScraperJob struct {
	Script      *models.ScraperScript
	ExecuteFunc ScraperExecuteFunc
}

ScraperJob represents a scraper script job

func (*ScraperJob) Execute

func (j *ScraperJob) Execute() error

Execute runs the scraper script

func (*ScraperJob) Name

func (j *ScraperJob) Name() string

Name returns the job name

type SubscriptionExpiryJob added in v1.9.0

type SubscriptionExpiryJob struct{}

SubscriptionExpiryJob checks for expired subscriptions and downgrades users

func (*SubscriptionExpiryJob) Execute added in v1.9.0

func (j *SubscriptionExpiryJob) Execute() error

func (*SubscriptionExpiryJob) Name added in v1.9.0

func (j *SubscriptionExpiryJob) Name() string

Jump to

Keyboard shortcuts

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