package downloader import "context" // EventType identifies an observer event emitted by Queue. type EventType string const ( EventStarted EventType = "started" EventProgress EventType = "progress" EventPaused EventType = "paused" EventCompleted EventType = "completed" EventFailed EventType = "failed" EventCanceled EventType = "canceled" ) // Event reports one generation of a download task. Done is monotonic within a // RequestID+Attempt pair. A new Attempt permits a reset to zero when a server // ignores Range or an entity cannot be safely resumed. type Event struct { Type EventType RequestID string AppID string Attempt uint64 Done int64 TotalKnown bool Total int64 SpeedBytesSec int64 CompletedPath string ErrorCode string } // Observer receives queue events. Implementations must honor context // cancellation so pause/cancel can wait for the old generation to exit. type Observer interface { PublishDownload(context.Context, Event) error } type discardObserver struct{} func (discardObserver) PublishDownload(context.Context, Event) error { return nil }