Documentation
¶
Overview ¶
Package progress provides progress tracking functionality for downloads.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager provides advanced progress tracking with moving averages and chunk tracking.
func (*Manager) GetProgress ¶
func (m *Manager) GetProgress() ProgressInfo
GetProgress returns the current progress.
func (*Manager) Start ¶
func (m *Manager) Start()
Start starts the progress manager with rate limiting.
func (*Manager) UpdateChunks ¶
UpdateChunks updates chunk completion status.
type Progress ¶
type Progress struct {
// TotalBytes is the total size of the download in bytes.
// Set to -1 if unknown.
TotalBytes int64
// DownloadedBytes is the number of bytes downloaded so far.
DownloadedBytes int64
// Speed is the current download speed in bytes per second.
Speed int64
// StartTime is when the download started.
StartTime time.Time
// LastUpdate is when the progress was last updated.
LastUpdate time.Time
// contains filtered or unexported fields
}
Progress represents the current state of a download operation.
func NewProgress ¶
func NewProgress(totalBytes int64, callback ProgressCallback) *Progress
NewProgress creates a new Progress instance with the specified parameters.
func (*Progress) ForceUpdate ¶
ForceUpdate forces an immediate progress update, bypassing rate limiting.
func (*Progress) GetSnapshot ¶
func (p *Progress) GetSnapshot() ProgressSnapshot
GetSnapshot returns a thread-safe snapshot of the current progress state.
type ProgressCallback ¶
type ProgressInfo ¶
type ProgressInfo struct {
TotalBytes int64
DownloadedBytes int64
Speed int64
TimeRemaining time.Duration
ChunksComplete int
TotalChunks int
StartTime time.Time
LastUpdateTime time.Time
}
ProgressInfo represents detailed progress information.
type ProgressReader ¶
type ProgressReader struct {
// contains filtered or unexported fields
}
ProgressReader wraps an io.Reader to track progress as data is read.
func NewProgressReader ¶
func NewProgressReader( reader io.Reader, totalBytes int64, callback ProgressCallback, ) *ProgressReader
NewProgressReader creates a new ProgressReader that wraps the given reader.
func (*ProgressReader) GetProgress ¶
func (pr *ProgressReader) GetProgress() *Progress
GetProgress returns the underlying progress tracker.
type ProgressSnapshot ¶
type ProgressSnapshot struct {
TotalBytes int64
DownloadedBytes int64
Speed int64
StartTime time.Time
LastUpdate time.Time
}
ProgressSnapshot represents a point-in-time snapshot of progress data.
func (ProgressSnapshot) ETA ¶
func (ps ProgressSnapshot) ETA() time.Duration
ETA returns the estimated time to completion. Returns -1 if total size is unknown or speed is zero.
func (ProgressSnapshot) Elapsed ¶
func (ps ProgressSnapshot) Elapsed() time.Duration
Elapsed returns the time elapsed since the download started.
func (ProgressSnapshot) Percentage ¶
func (ps ProgressSnapshot) Percentage() float64
Percentage returns the completion percentage (0-100). Returns -1 if total size is unknown.
func (ProgressSnapshot) String ¶
func (ps ProgressSnapshot) String() string
String returns a human-readable representation of the progress.
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter controls the frequency of progress updates to avoid overwhelming the callback with too many updates.
func NewRateLimiter ¶
func NewRateLimiter(interval time.Duration) *RateLimiter
NewRateLimiter creates a new rate limiter with the specified minimum interval.
func (*RateLimiter) Allow ¶
func (rl *RateLimiter) Allow() bool
Allow returns true if enough time has passed since the last update.