events

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeProgress = "progress"
	EventTypeStarted  = "started"
	EventTypeComplete = "complete"
	EventTypeError    = "error"
	EventTypePaused   = "paused"
	EventTypeResumed  = "resumed"
	EventTypeQueued   = "queued"
	EventTypeRemoved  = "removed"
	EventTypeRequest  = "request"
	EventTypeSystem   = "system"
)

Variables

This section is empty.

Functions

func DecodeSSEMessage

func DecodeSSEMessage(eventType string, data []byte) (interface{}, bool, error)

DecodeSSEMessage decodes one SSE event payload into the corresponding message.

func EventTypeForMessage

func EventTypeForMessage(msg interface{}) (string, bool)

EventTypeForMessage maps message payloads to SSE event type names.

Types

type BatchProgressMsg

type BatchProgressMsg []ProgressMsg

BatchProgressMsg represents a batch of progress updates to reduce TUI render calls

type DownloadCompleteMsg

type DownloadCompleteMsg struct {
	DownloadID string
	Filename   string
	Elapsed    time.Duration
	Total      int64
	AvgSpeed   float64 // Average download speed in bytes/sec
}

DownloadCompleteMsg signals that the download finished successfully

type DownloadErrorMsg

type DownloadErrorMsg struct {
	DownloadID string
	Filename   string
	DestPath   string
	Err        error
}

DownloadErrorMsg signals that an error occurred

func (DownloadErrorMsg) MarshalJSON

func (m DownloadErrorMsg) MarshalJSON() ([]byte, error)

func (*DownloadErrorMsg) UnmarshalJSON

func (m *DownloadErrorMsg) UnmarshalJSON(data []byte) error

type DownloadPausedMsg

type DownloadPausedMsg struct {
	DownloadID string
	Filename   string
	Downloaded int64
	State      *types.DownloadState `json:"-"`
}

type DownloadQueuedMsg

type DownloadQueuedMsg struct {
	DownloadID string
	Filename   string
	URL        string
	DestPath   string
	Mirrors    []string
}

type DownloadRemovedMsg

type DownloadRemovedMsg struct {
	DownloadID string
	Filename   string
	DestPath   string
	Completed  bool
}

type DownloadRequestMsg

type DownloadRequestMsg struct {
	ID       string
	URL      string
	Filename string
	Path     string
	Mirrors  []string
	Headers  map[string]string
}

DownloadRequestMsg signals a request to start a download (e.g. from extension) that may need user confirmation or duplicate checking

type DownloadResumedMsg

type DownloadResumedMsg struct {
	DownloadID string
	Filename   string
}

type DownloadStartedMsg

type DownloadStartedMsg struct {
	DownloadID string
	URL        string
	Filename   string
	Total      int64
	DestPath   string               // Full path to the destination file
	State      *types.ProgressState `json:"-"`
}

DownloadStartedMsg is sent when a download actually starts (after metadata fetch)

type ProgressMsg

type ProgressMsg struct {
	DownloadID        string
	Downloaded        int64
	Total             int64
	Speed             float64 // bytes per second
	Elapsed           time.Duration
	ActiveConnections int
	ChunkBitmap       []byte
	BitmapWidth       int
	ActualChunkSize   int64
	ChunkProgress     []int64
}

ProgressMsg represents a progress update from the downloader

type SSEMessage

type SSEMessage struct {
	Event string
	Data  []byte
}

SSEMessage represents one server-sent event frame.

func EncodeSSEMessages

func EncodeSSEMessages(msg interface{}) ([]SSEMessage, error)

EncodeSSEMessages converts an event payload into one or more SSE messages. BatchProgressMsg is flattened into multiple "progress" events.

type SystemLogMsg

type SystemLogMsg struct {
	Message string
}

SystemLogMsg carries informational system-level log messages for clients/UI.

Jump to

Keyboard shortcuts

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