storage

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package storage provides persistent state using bbolt (pure-Go key-value store). Stores queue state and download history so they survive restarts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HistoryEntry

type HistoryEntry struct {
	ID              string    `json:"id"`
	Name            string    `json:"name"`
	Category        string    `json:"category"`
	Status          string    `json:"status"` // "completed" or "failed"
	Error           string    `json:"error,omitempty"`
	TotalBytes      int64     `json:"total_bytes"`
	DownloadedBytes int64     `json:"downloaded_bytes"`
	TotalSegments   int       `json:"total_segments"`
	FailedSegments  int64     `json:"failed_segments"`
	AddedAt         time.Time `json:"added_at"`
	StartedAt       time.Time `json:"started_at"`
	CompletedAt     time.Time `json:"completed_at"`
	Duration        string    `json:"duration"`
}

HistoryEntry represents a completed or failed download.

type JobRecord

type JobRecord struct {
	ID              string    `json:"id"`
	Name            string    `json:"name"`
	NZBPath         string    `json:"nzb_path"`
	Category        string    `json:"category"`
	Priority        int       `json:"priority"`
	Status          string    `json:"status"`
	AddedAt         time.Time `json:"added_at"`
	StartedAt       time.Time `json:"started_at,omitempty"`
	DoneAt          time.Time `json:"done_at,omitempty"`
	Error           string    `json:"error,omitempty"`
	TotalSegments   int       `json:"total_segments"`
	DoneSegments    int64     `json:"done_segments"`
	TotalBytes      int64     `json:"total_bytes"`
	DownloadedBytes int64     `json:"downloaded_bytes"`
	FailedSegments  int64     `json:"failed_segments"`
}

JobRecord is a serializable representation of a queue job. queue.Job has sync/atomic fields that can't be serialized directly.

type Store

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

Store wraps a bbolt database for job and history persistence.

func Open

func Open(path string) (*Store, error)

Open creates or opens a bbolt database at the given path.

func (*Store) ClearHistory added in v0.3.4

func (s *Store) ClearHistory() error

ClearHistory removes all history entries.

func (*Store) Close

func (s *Store) Close() error

Close closes the database.

func (*Store) CountHistory

func (s *Store) CountHistory() int

CountHistory returns the number of history entries.

func (*Store) DeleteHistory

func (s *Store) DeleteHistory(id string) error

DeleteHistory removes a history entry.

func (*Store) DeleteJob

func (s *Store) DeleteJob(id string) error

DeleteJob removes a job record.

func (*Store) GetJob

func (s *Store) GetJob(id string) (*JobRecord, error)

GetJob retrieves a single job by ID.

func (*Store) ListHistory

func (s *Store) ListHistory(limit int) ([]*HistoryEntry, error)

ListHistory returns history entries, newest first.

func (*Store) ListJobs

func (s *Store) ListJobs() ([]*JobRecord, error)

ListJobs returns all persisted jobs.

func (*Store) SaveHistory

func (s *Store) SaveHistory(entry *HistoryEntry) error

SaveHistory persists a history entry.

func (*Store) SaveJob

func (s *Store) SaveJob(job *JobRecord) error

SaveJob persists a job record.

Jump to

Keyboard shortcuts

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