cachefill

package
v0.2.11 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package cachefill maintains an opt-in, bounded local shelf of complete media sources. It fills sequentially at background priority and never writes watch history. The manifest and segment pins are node-local.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	core.SegmentCache
	ReleaseBytes(string) int64
	Pins() map[string][]string
	Describe(string, string, int64)
}

type Catalog

type Catalog interface {
	Browse(context.Context, core.BrowseQuery) (core.Page, error)
	CachedTitle(context.Context, core.RatingKey) (*core.Title, error)
	Children(context.Context, core.RatingKey) ([]core.Title, error)
}

type Deps

type Deps struct {
	Shared *SharedStore // nil for a node-local shelf
	// Household returns active members of the configured household scope.
	Household func(context.Context, string) ([]core.User, error)
	State     WatchReader
	Now       func() time.Time
	Catalog   Catalog
	Resolver  core.Resolver
	Engine    Engine
	Cache     Cache
	Owner     func(context.Context) (*core.User, error)
	Config    func() config.Cache
	Active    func() bool
	FreeBytes func() (int64, error)
	Remember  func(context.Context, *core.User, core.RatingKey, core.ClientCaps, *core.Resolution) error
	Logger    *slog.Logger
}

type Engine

type Engine interface {
	core.Engine
	DurablePrefetch(context.Context, string, []byte, int64, int64) error
}

type Item

type Item struct {
	Key         core.RatingKey `json:"key"`
	Title       string         `json:"title"`
	ReleaseID   string         `json:"releaseId"`
	Size        int64          `json:"size"`
	Complete    bool           `json:"complete"`
	Reason      string         `json:"reason,omitempty"`
	Score       float64        `json:"score,omitempty"`
	StoredBytes int64          `json:"storedBytes"`
	Updated     time.Time      `json:"updated"`
}

type Manager

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

func New

func New(dir string, d Deps) (*Manager, error)

func (*Manager) Pause

func (m *Manager) Pause(v bool) error

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

func (*Manager) Status

func (m *Manager) Status() Status

func (*Manager) Wake

func (m *Manager) Wake()

Wake cancels an old-policy job before scheduling a pass with current settings.

type Selection

type Selection struct {
	Key       core.RatingKey `json:"key"`
	Title     string         `json:"title"`
	Type      core.MediaType `json:"type"`
	Score     float64        `json:"score"`
	Catalogue float64        `json:"catalogue"`
	Household float64        `json:"household"`
	Reason    string         `json:"reason"`
}

type SharedStore

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

SharedStore keeps the shelf in the server database and fences every manifest/pin mutation with a renewable epoch. A former worker cannot unpin a new worker's shelf after losing its lease. The NAS holds media bytes only.

func NewSharedStore

func NewSharedStore(db *sql.DB, node string) *SharedStore

type Status

type Status struct {
	State     string      `json:"state"`
	Message   string      `json:"message"`
	Title     string      `json:"title"`
	Fetched   int64       `json:"fetched"`
	Size      int64       `json:"size"`
	Allocated int64       `json:"allocated"`
	Ready     int         `json:"ready"`
	Failed    int         `json:"failed"`
	Paused    bool        `json:"paused"`
	Selection []Selection `json:"selection"`
	Viewers   int         `json:"viewers"`
	Items     []Item      `json:"items"`
}

type WatchReader

type WatchReader interface {
	History(context.Context, int64, time.Time, int) ([]core.HistoryEntry, error)
	InProgress(context.Context, int64, int) ([]core.WatchStatus, error)
}

WatchReader deliberately cannot write history. Preloading is never a view.

Jump to

Keyboard shortcuts

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