Documentation ¶
Index ¶
Constants ¶
const ( // ScaleGiB is the scale for computing IEC Gibibytes ScaleGiB = IECScale(30) // ScaleMiB is the scale for computing IEC Mebibytes ScaleMiB = IECScale(20) // ScaleKiB is the scale for computing IEC Kibibytes ScaleKiB = IECScale(10) // ScaleBiB is the base scale for representing a number of bytes ScaleBiB = IECScale(1) // ReceivingObjects represents progress from counting received objects ReceivingObjects UpdateType = iota // ResolvingDeltas represents progress from counting resolved deltas ResolvingDeltas )
const (
// ThroughputRateSlotCount is the number of samples used to calculate rate
ThroughputRateSlotCount = 8
)
Variables ¶
This section is empty.
Functions ¶
func ToIEC ¶
ToIEC converts a size of bytes into the corresponding IEC unit SEE: https://github.com/git/git/blob/be8661a3286c67a5d4088f4226cbd7f8b76544b0/strbuf.c#L830-L869
func ToIECString ¶
ToIECString returns a string representation of a size of bytes including its IEC unit Example: 3.14 GiB
Types ¶
type Collector ¶
Collector collects data to send progress updates
func NewCollector ¶
NewCollector creates a Collector
func (*Collector) Read ¶
Read satisfies the io.Reader interface; sends bytes read to the background process to be tracked
func (*Collector) ReceiveObject ¶
ReceiveObject sends an object to the background process to be tracked
func (*Collector) ResolveDelta ¶
ResolveDelta sends an object to the background process to be tracked
type CountingUpdate ¶
type CountingUpdate struct { Type UpdateType Count uint32 Max uint32 }
CountingUpdate holds the part and whole for calculating percentage of progress
type IECScale ¶
type IECScale uint64
IECScale is a number used to represent bytes at various scales (GiB, MiB, KiB, bytes)
type Reporter ¶
Reporter sends digested progress updates
func NewReporter ¶
NewReporter creates a new Reporter
type Throughput ¶
type Throughput struct { CurrentTotal uint64 PreviousTotal uint64 PreviousNanoseconds uint64 AverageBytes uint64 AverageMisecs uint64 // a "misec" is 1/1024 sec LastBytes []uint64 // size = 8 LastMisecs []uint64 // size = 8; "misec" is 1/1024 sec Index uint32 }
Throughput calculates the rate that data is read
func (*Throughput) AdvanceBytesRead ¶
func (t *Throughput) AdvanceBytesRead(bytesRead int)
AdvanceBytesRead tracks the number of bytes read
func (*Throughput) AdvanceTime ¶
func (t *Throughput) AdvanceTime(now int64) uint64
AdvanceTime tracks the progress and returns the current rate of bytes being read SEE: https://github.com/git/git/blob/be8661a3286c67a5d4088f4226cbd7f8b76544b0/progress.c#L186-L244
type Update ¶
type Update struct { Type UpdateType Count uint32 Max uint32 BytesReceived uint64 Rate uint64 }
Update is what the consuming code will get notified with
func (*Update) BytesReceivedIEC ¶
BytesReceivedIEC returns the IEC representation of BytesReceived, e.g. GiB, MiB, KiB
func (*Update) Percentage ¶
Percentage calculates the completion percentage