Help us shape the future of Go! Take the 2026 Go Developer Survey

progress

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broadcaster

type Broadcaster interface {
	UpdateProgress(queueID int, percentage int)
	UpdateProgressWithStage(queueID int, percentage int, stage string)
}

Broadcaster interface for updating progress

type ProgressBroadcaster

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

ProgressBroadcaster manages progress tracking for queue items

func NewProgressBroadcaster

func NewProgressBroadcaster() *ProgressBroadcaster

NewProgressBroadcaster creates a new progress broadcaster

func (*ProgressBroadcaster) BroadcastHealthChanged

func (pb *ProgressBroadcaster) BroadcastHealthChanged()

BroadcastHealthChanged sends a health-change notification to all SSE subscribers. Uses QueueID=0 and Status="health_changed" as a sentinel for health state changes.

func (*ProgressBroadcaster) BroadcastQueueChanged

func (pb *ProgressBroadcaster) BroadcastQueueChanged()

BroadcastQueueChanged sends a queue-change notification to all SSE subscribers. Uses QueueID=0 and Status="queue_changed" as a sentinel for non-progress queue events.

func (*ProgressBroadcaster) ClearProgress

func (pb *ProgressBroadcaster) ClearProgress(queueID int)

ClearProgress removes progress tracking for a completed or failed queue item

func (*ProgressBroadcaster) Close

func (pb *ProgressBroadcaster) Close() error

func (*ProgressBroadcaster) CreateTracker

func (pb *ProgressBroadcaster) CreateTracker(queueID, minPercent, maxPercent int) *Tracker

CreateTracker creates a progress tracker for a specific queue item with a percentage range

func (*ProgressBroadcaster) GetAllProgress

func (pb *ProgressBroadcaster) GetAllProgress() map[int]ProgressEntry

GetAllProgress returns a copy of all current progress states including stage labels. The returned map is used to build the initial SSE payload sent to new subscribers.

func (*ProgressBroadcaster) GetProgress

func (pb *ProgressBroadcaster) GetProgress(queueID int) (int, bool)

GetProgress returns the current progress percentage for a queue item.

func (*ProgressBroadcaster) HasSubscribers

func (pb *ProgressBroadcaster) HasSubscribers() bool

HasSubscribers reports whether at least one SSE client is connected.

func (*ProgressBroadcaster) NotifyComplete

func (pb *ProgressBroadcaster) NotifyComplete(queueID int, status string)

NotifyComplete broadcasts a terminal completion or failure event for a queue item and removes it from progress tracking. status should be "completed" or "failed".

func (*ProgressBroadcaster) NotifyStreamable added in v0.3.0

func (pb *ProgressBroadcaster) NotifyStreamable(queueID int, storagePath string)

NotifyStreamable broadcasts an early-mount event for a queue item. The storage path is available and the file is accessible via the VFS before post-processing completes. Stremio waiters can return stream URLs immediately on this signal.

func (*ProgressBroadcaster) Subscribe

func (pb *ProgressBroadcaster) Subscribe() (string, <-chan ProgressUpdate)

Subscribe creates a new SSE subscriber and returns a subscription ID and update channel

func (*ProgressBroadcaster) Unsubscribe

func (pb *ProgressBroadcaster) Unsubscribe(subID string)

Unsubscribe removes an SSE subscriber and closes its channel

func (*ProgressBroadcaster) UpdateProgress

func (pb *ProgressBroadcaster) UpdateProgress(queueID int, percentage int)

UpdateProgress updates the progress for a queue item (no stage label).

func (*ProgressBroadcaster) UpdateProgressWithStage

func (pb *ProgressBroadcaster) UpdateProgressWithStage(queueID int, percentage int, stage string)

UpdateProgressWithStage updates the progress for a queue item with an optional stage label.

type ProgressEntry

type ProgressEntry struct {
	Percentage int    `json:"percentage"`
	Stage      string `json:"stage,omitempty"`
}

ProgressEntry holds the current progress state for a single queue item. It is returned by GetAllProgress for the SSE initial payload.

type ProgressTracker

type ProgressTracker interface {
	Update(current, total int)
	UpdateAbsolute(percentage int)
}

ProgressTracker interface for types that can report progress

type ProgressUpdate

type ProgressUpdate struct {
	QueueID     int       `json:"queue_id"`
	Percentage  int       `json:"percentage"`
	Stage       string    `json:"stage,omitempty"`        // e.g. "Parsing NZB", "Validating segments"
	Status      string    `json:"status,omitempty"`       // "completed", "failed", or "streamable" on terminal/early events
	StoragePath string    `json:"storage_path,omitempty"` // set when Status="streamable"
	Timestamp   time.Time `json:"timestamp"`
}

ProgressUpdate represents a progress update event

type Tracker

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

Tracker encapsulates progress updates for a specific queue item

func NewTracker

func NewTracker(broadcaster Broadcaster, queueID, minPercent, maxPercent int) *Tracker

NewTracker creates a progress tracker for a specific queue item with a percentage range

func (*Tracker) Slice added in v0.2.1

func (pt *Tracker) Slice(idx, count int) *Tracker

Slice returns a child tracker covering segment idx of count equal slices of this tracker's [min,max] range. Useful for dividing a range across a known number of sequential sub-operations (e.g. one slice per ISO across a multi-disc group). Safe on a nil receiver (returns nil).

func (*Tracker) Update

func (pt *Tracker) Update(current, total int)

Update reports progress within the configured percentage range. Safe to call on a nil receiver (no-op).

func (*Tracker) UpdateAbsolute

func (pt *Tracker) UpdateAbsolute(percentage int)

UpdateAbsolute reports an absolute percentage value, bypassing the tracker's range. The stored stage label is still attached to the broadcast update.

func (*Tracker) WithStage

func (pt *Tracker) WithStage(stage string) *Tracker

WithStage sets a human-readable stage label that is attached to every progress update emitted by this tracker. Returns the same tracker for chaining.

Jump to

Keyboard shortcuts

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