Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ComputeStats ¶
type ComputeStats struct {
// contains filtered or unexported fields
}
ComputeStats type supports computing running average with a given window size.
func NewComputeStats ¶
func NewComputeStats(size int) *ComputeStats
NewComputeStats returns a new instance of ComputeStats. The parameter size is the maximum number of values that ComputeStats track at any given point of time.
func NewComputestateDefaultSize ¶
func NewComputestateDefaultSize() *ComputeStats
NewComputestateDefaultSize returns a new instance of ComputeStats that can tracks maximum of 60 values.
func (*ComputeStats) ComputeAvg ¶
func (s *ComputeStats) ComputeAvg(current float64) float64
ComputeAvg adds the given value to a list containing set of previous values added and returns the average of the values in the list. If the values list reached the maximum size then oldest value will be removed
type ReaderWithProgress ¶
type ReaderWithProgress struct { ProgressChan <-chan *Record // contains filtered or unexported fields }
ReaderWithProgress wraps an io.ReadCloser, it track and report the read progress.
func NewReaderWithProgress ¶
func NewReaderWithProgress(inner io.ReadCloser, sizeInBytes int64, progressIntervalInSeconds time.Duration) *ReaderWithProgress
NewReaderWithProgress creates a new instance of ReaderWithProgress. The parameter inner is the inner stream whose read progress needs to be tracked, sizeInBytes is the total size of the inner stream in bytes, progressIntervalInSeconds is the interval at which the read progress needs to be send to ProgressChan channel. After using the this reader, it must be closed by calling Close method to avoid goroutine leak.
func (*ReaderWithProgress) Close ¶
func (r *ReaderWithProgress) Close() error
Close closes the inner stream and stop reporting read progress in the ProgressChan chan.
type Record ¶
type Record struct { PercentComplete float64 AverageThroughputMbPerSecond float64 RemainingDuration time.Duration BytesProcessed int64 }
Record type is used by the ProgressStatus to report the progress at regular interval.
type Status ¶
type Status struct {
// contains filtered or unexported fields
}
Status can be used by a collection of workers (reporters) to report the amount of work done when they need, Status compute the overall progress at regular interval and report it.
func NewStatus ¶
func NewStatus(reportersCount int, alreadyProcessedBytes, totalBytes int64, computeStats *ComputeStats) *Status
NewStatus creates a new instance of Status. reporterCount is the number of concurrent goroutines that want to report processed bytes count, alreadyProcessedBytes is the bytes already processed if any, the parameter totalBytes is the total number of bytes that the reports will be process eventually, the parameter computeStats is used to calculate the running average.
func (*Status) Close ¶
func (s *Status) Close()
Close disposes this ProgressStatus instance, an attempt to invoke ReportBytesProcessedCount method on a closed instance will be panic. Close also stops sending progress to the channel returned by Run method. Not calling Close will cause goroutine leak.
func (*Status) ReportBytesProcessedCount ¶
ReportBytesProcessedCount method is used to report the number of bytes processed.
func (*Status) Run ¶
Run starts counting the reported processed bytes count and compute the progress, this method returns a channel, the computed progress will be send to this channel in regular interval. Once done with using ProgressStatus instance, you must call Dispose method otherwise there will be go routine leak.