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 ¶
- type HistoryEntry
- type JobRecord
- type Store
- func (s *Store) ClearHistory() error
- func (s *Store) Close() error
- func (s *Store) CountHistory() int
- func (s *Store) DeleteHistory(id string) error
- func (s *Store) DeleteJob(id string) error
- func (s *Store) GetJob(id string) (*JobRecord, error)
- func (s *Store) ListHistory(limit int) ([]*HistoryEntry, error)
- func (s *Store) ListJobs() ([]*JobRecord, error)
- func (s *Store) SaveHistory(entry *HistoryEntry) error
- func (s *Store) SaveJob(job *JobRecord) error
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 (*Store) ClearHistory ¶ added in v0.3.4
ClearHistory removes all history entries.
func (*Store) CountHistory ¶
CountHistory returns the number of history entries.
func (*Store) DeleteHistory ¶
DeleteHistory removes a history entry.
func (*Store) ListHistory ¶
func (s *Store) ListHistory(limit int) ([]*HistoryEntry, error)
ListHistory returns history entries, newest first.
func (*Store) SaveHistory ¶
func (s *Store) SaveHistory(entry *HistoryEntry) error
SaveHistory persists a history entry.
Click to show internal directories.
Click to hide internal directories.