Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
Config *config.Config
Logger *logger.Logger
// High-level interfaces for services to use
NNTP NNTPManager
Indexer IndexerManager
Processor Processor
Downloader Downloader
Queue QueueManager
NZBParser NZBParser
Store Store
ExtractionEnabled bool
}
Context hold the core environment and shared resources for GoNZB. It acts as the "Single Source of Truth" for the application state.
func NewContext ¶
NewContext initializes the base environment.
type Downloader ¶ added in v0.5.0
type IndexerManager ¶ added in v0.5.0
type IndexerManager interface {
SearchAll(ctx context.Context, query string) ([]*domain.Release, error)
GetNZB(ctx context.Context, res *domain.Release) (io.ReadCloser, error)
GetResultByID(ctx context.Context, id string) (*domain.Release, error)
}
Manager defines the contract for our NZB search and download engine.
type NNTPManager ¶
type Processor ¶
type Processor interface {
// This allows the engine to trigger repair/extract without importing processor
Prepare(ctx context.Context, nzbModel *nzb.Model, nzbFilename string) (*domain.PreparationResult, error)
Finalize(ctx context.Context, tasks []*domain.DownloadFile) error
PostProcess(ctx context.Context, tasks []*domain.DownloadFile) error
}
type QueueManager ¶ added in v0.5.0
type QueueManager interface {
Start(ctx context.Context)
Add(ctx context.Context, releaseID string, title string) (*domain.QueueItem, error)
GetActiveItem() *domain.QueueItem
GetItem(ctx context.Context, id string) (*domain.QueueItem, bool)
GetAllItems() []*domain.QueueItem
Cancel(id string) bool
HydrateItem(ctx context.Context, item *domain.QueueItem) error
UpdateStatus(ctx context.Context, item *domain.QueueItem, status domain.JobStatus)
}
type Store ¶ added in v0.5.0
type Store interface {
// Metadata: SQLLite
UpsertReleases(ctx context.Context, results []*domain.Release) error
GetRelease(ctx context.Context, id string) (*domain.Release, error)
SearchReleases(ctx context.Context, query string) ([]*domain.Release, error)
UpdateReleaseHash(ctx context.Context, id string, hash string) error
GetReleaseByHash(ctx context.Context, hash string) (*domain.Release, error)
// Downloader Queue: SQLite
SaveQueueItem(ctx context.Context, item *domain.QueueItem) error
GetQueueItem(ctx context.Context, id string) (*domain.QueueItem, error)
GetQueueItems(ctx context.Context) ([]*domain.QueueItem, error)
GetActiveQueueItems(ctx context.Context) ([]*domain.QueueItem, error)
ResetStuckQueueItems(ctx context.Context, newStatus domain.JobStatus, oldStatuses ...domain.JobStatus) error
// release_files: SQLite
SaveReleaseFiles(ctx context.Context, releaseID string, files []*domain.DownloadFile) error
GetReleaseFiles(ctx context.Context, releaseID string) ([]*domain.DownloadFile, error)
// Blobs: File System
GetNZBReader(key string) (io.ReadCloser, error)
CreateNZBWriter(key string) (io.WriteCloser, error)
Exists(key string) bool
Close() error
}
Store defines the contract for NZB storage. Allows to use a simple directory FileCache, or Redis / DB / S3 for NZB storage in the future. Should be StoreManager similar to others, but we'll just use FileCache and keep it simple for now.
Click to show internal directories.
Click to hide internal directories.