app

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

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

func NewContext(cfg *config.Config, log *logger.Logger) (*Context, error)

NewContext initializes the base environment.

func (*Context) Close added in v0.5.0

func (ctx *Context) Close()

type Downloader added in v0.5.0

type Downloader interface {
	// The engine's ability to process a specific item
	Download(ctx context.Context, item *domain.QueueItem) error
	RenderCLIProgress(item *domain.QueueItem, speedMbps float64, final bool)
	SetProgressHandler(fn func(*domain.QueueItem))
}

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 NNTPManager interface {
	// This allows the engine to call the manager without importing the nntp package
	Fetch(ctx context.Context, seg *domain.Segment, groups []string) (io.Reader, error)
	TotalCapacity() int
}

type NZBParser added in v0.5.0

type NZBParser interface {
	ParseFile(nzbPath string) (*nzb.Model, error)
	Parse(r io.Reader) (*nzb.Model, error)
}

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.

Jump to

Keyboard shortcuts

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