app

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyEffectiveConfig added in v0.6.0

func ApplyEffectiveConfig(appCtx *Context, effective *config.Config) error

CHANGED: safe runtime application for effective config. This only rebuilds Aggregator + Resolver from effective config. Downloader and Usenet/NZB Indexer runtime-specific rebuilds stay in cmd wiring.

func LoadAndApplyEffectiveConfig added in v0.6.0

func LoadAndApplyEffectiveConfig(ctx context.Context, appCtx *Context) error

CHANGED: load effective config from SQLite settings overlay and apply safe in-memory config/runtime swaps that do not create package cycles.

Types

type ArrNotifier added in v0.6.0

type ArrNotifier interface {
	NotifyQueueTerminal(ctx context.Context, item *domain.QueueItem) error
}

type BlobStore added in v0.6.0

type BlobStore interface {
	// Blobs: File System
	GetNZBReader(key string) (io.ReadCloser, error)
	CreateNZBWriter(key string) (io.WriteCloser, error)
	SaveNZBAtomically(key string, data []byte) error
	Exists(key string) bool
}

type Context

type Context struct {
	BootstrapConfig *config.Config
	Config          *config.Config
	Logger          *logger.Logger

	// High-level interfaces for services to use
	NNTP              NNTPManager
	Aggregator        IndexerAggregator
	Resolver          ReleaseResolver
	UsenetIndexer     UsenetIndexerService
	Processor         Processor
	Downloader        Downloader
	Queue             QueueManager
	NZBParser         NZBParser
	JobStore          JobStore
	QueueFileStore    QueueFileStore
	BlobStore         BlobStore
	PayloadFetcher    PayloadFetcher
	PayloadCacheStore PayloadCacheStore
	SettingsStore     SettingsStore
	PGIndexStore      *pgindex.Store
	ArrNotifier       ArrNotifier

	ExtractionEnabled bool
	// contains filtered or unexported fields
}

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 context based on enabled modules

func (*Context) AddCloser added in v0.6.0

func (ctx *Context) AddCloser(c io.Closer)

allow runtime wiring (from main) to register additional closers.

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 IndexerAggregator added in v0.6.0

type IndexerAggregator interface {
	SearchAll(ctx context.Context, query string) ([]*domain.Release, error)
	SearchAllWithRequest(ctx context.Context, req aggregatorpkg.SearchRequest) ([]*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 JobStore added in v0.6.0

type JobStore interface {
	// 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)
	DeleteQueueItems(ctx context.Context, ids []string) (int64, error)
	ClearQueueHistory(ctx context.Context, statuses []domain.JobStatus) (int64, error)
	SaveQueueEvent(ctx context.Context, ev *domain.QueueItemEvent) error
	GetQueueEvents(ctx context.Context, queueID string) ([]*domain.QueueItemEvent, error)
	ResetStuckQueueItems(ctx context.Context, newStatus domain.JobStatus, oldStatuses ...domain.JobStatus) error

	// store liveness + schema handshake.
	Ping(ctx context.Context) error
	SchemaVersion(ctx context.Context) (int, error)
	ExpectedSchemaVersion() int
	ValidateSchema(ctx context.Context) error
}

JobStore defines downloader queue/event/history persistence.

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
	Close() error // allows idle runtime swaps on settings reload
}

type NZBParser added in v0.5.0

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

type PayloadCacheStore added in v0.6.0

type PayloadCacheStore interface {
	GetNZBReader(key string) (io.ReadCloser, error)
	CreateNZBWriter(key string) (io.WriteCloser, error)
	SaveNZBAtomically(key string, data []byte) error
	Exists(key string) bool
}

type PayloadFetcher added in v0.6.0

type PayloadFetcher interface {
	GetNZB(ctx context.Context, sourceKind string, res *domain.Release) (io.ReadCloser, error)
}

payload fetch now routes by persisted source kind.

type Processor

type Processor interface {
	// processor now needs the queue item so it can use a per-job work dir
	Prepare(ctx context.Context, item *domain.QueueItem, nzbModel *nzb.Model, nzbFilename string) (*domain.PreparationResult, error)
	Finalize(ctx context.Context, tasks []*domain.DownloadFile) error
	PostProcess(ctx context.Context, item *domain.QueueItem, tasks []*domain.DownloadFile) error
}

type QueueAddRequest added in v0.6.0

type QueueAddRequest struct {
	SourceKind      string
	SourceReleaseID string
	Release         *domain.Release
	Title           string
}

explicit queue enqueue contract so downloader does not infer source provenance.

type QueueFileStore added in v0.6.0

type QueueFileStore interface {
	SaveQueueItemFiles(ctx context.Context, queueItemID string, files []*domain.DownloadFile) error
	GetQueueItemFiles(ctx context.Context, queueItemID string) ([]*domain.DownloadFile, error)
}

downloader-owned queue item file metadata

type QueueManager added in v0.5.0

type QueueManager interface {
	Start(ctx context.Context)
	Add(ctx context.Context, req QueueAddRequest) (*domain.QueueItem, error)
	GetActiveItem() *domain.QueueItem
	GetItem(ctx context.Context, id string) (*domain.QueueItem, bool)
	GetAllItems() []*domain.QueueItem
	Cancel(id string) bool
	Delete(id string) bool

	Pause() bool
	Resume() bool
	IsPaused() bool

	HydrateItem(ctx context.Context, item *domain.QueueItem) error
	UpdateStatus(ctx context.Context, item *domain.QueueItem, status domain.JobStatus)
	ReloadRuntime(appCtx *Context) // refresh future-job dependencies after settings reload
}

type ReleaseResolver added in v0.6.0

type ReleaseResolver interface {
	GetRelease(ctx context.Context, sourceKind, sourceReleaseID string) (*domain.Release, error)
	GetNZB(ctx context.Context, sourceKind string, res *domain.Release) (io.ReadCloser, error)
}

resolver routes by source kind instead of assuming aggregator-only resolution.

type SettingsStore added in v0.6.0

type SettingsStore interface {
	LoadEffectiveSettings(ctx context.Context, base *config.Config) (*config.Config, error)
	GetRuntimeSettings(ctx context.Context, base ...*config.Config) (*settingsstore.RuntimeSettings, error)
	UpdateSettings(ctx context.Context, patch any) error
	WatchSettingsChanges(ctx context.Context) (<-chan struct{}, error)

	// store liveness + schema handshake.
	Ping(ctx context.Context) error
	SchemaVersion(ctx context.Context) (int, error)
	ExpectedSchemaVersion() int
	ValidateSchema(ctx context.Context) error
}

Runtime settings

type UsenetIndexCatalog added in v0.6.0

type UsenetIndexCatalog interface {
	GetCatalogReleaseByID(ctx context.Context, releaseID string) (*domain.Release, error)
}

minimal PG catalog boundary for Milestone 7 resolver routing.

type UsenetIndexerService added in v0.6.0

type UsenetIndexerService interface {
	ScrapeOnce(ctx context.Context) error
	ScrapeLatestOnce(ctx context.Context) error
	ScrapeBackfillOnce(ctx context.Context) error
	AssembleOnce(ctx context.Context) error
	ReleaseOnce(ctx context.Context) error
	RunPipelineOnce(ctx context.Context) error
	Start(ctx context.Context, interval time.Duration) error
}

Jump to

Keyboard shortcuts

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