Documentation
¶
Index ¶
- Constants
- func DecodeSSEMessage(eventType string, data []byte) (interface{}, bool, error)
- func EventTypeForMessage(msg interface{}) (string, bool)
- type BatchProgressMsg
- type DownloadCompleteMsg
- type DownloadErrorMsg
- type DownloadPausedMsg
- type DownloadQueuedMsg
- type DownloadRemovedMsg
- type DownloadRequestMsg
- type DownloadResumedMsg
- type DownloadStartedMsg
- type ProgressMsg
- type SSEMessage
- type SystemLogMsg
Constants ¶
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 ¶
DecodeSSEMessage decodes one SSE event payload into the corresponding message.
func EventTypeForMessage ¶
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 ¶
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 DownloadRemovedMsg ¶
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 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 ¶
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.