Documentation
¶
Index ¶
- Constants
- Variables
- func NewBytesReporterContext(ctx context.Context, reporter *BytesReporter) context.Context
- func NewContext(ctx context.Context, updateFunc ReportProgress) context.Context
- func NewReporterReader(parent io.Reader, reportProgress ReportRead) *reporterReader
- func NewReporterWriter(parent io.Writer, reportProgress ReportWrite) *reporterWriter
- type BytesReporter
- type ReportProgress
- type ReportRead
- type ReportWrite
- type Units
- type UnitsReporter
Constants ¶
View Source
const ( UnitsNone = iota UnitsBytes )
Variables ¶
View Source
var ErrorProgressDone = errors.New("Progress is done")
Not a real error, just a flag that can be used to tell progress reporter that this process is Done
Functions ¶
func NewBytesReporterContext ¶
func NewBytesReporterContext( ctx context.Context, reporter *BytesReporter, ) context.Context
func NewContext ¶
func NewContext(ctx context.Context, updateFunc ReportProgress) context.Context
Insert a progress reporting function in the context
This serves kind of like an interface, as the implementation of what to do when progress is reported is done by the caller
func NewReporterReader ¶
func NewReporterReader(parent io.Reader, reportProgress ReportRead) *reporterReader
Wraps an io.Reader in another Reader which reports the amount of bytes read anytime the parent is read
func NewReporterWriter ¶
func NewReporterWriter(parent io.Writer, reportProgress ReportWrite) *reporterWriter
Types ¶
type BytesReporter ¶
type BytesReporter struct {
// contains filtered or unexported fields
}
func BytesReporterFromContext ¶
func BytesReporterFromContext(ctx context.Context) *BytesReporter
func NewBytesReporter ¶
func NewBytesReporter( ctx context.Context, name string, size uint64, ) *BytesReporter
func (*BytesReporter) End ¶
func (r *BytesReporter) End()
func (*BytesReporter) Report ¶
func (r *BytesReporter) Report(bytes uint64, err error)
Report the amount of new bytes progressed, if any, and an error, if any. Nil-pointer safe
func (*BytesReporter) Start ¶
func (r *BytesReporter) Start()
type ReportProgress ¶
Progress reporting function signature
func FromContext ¶
func FromContext(ctx context.Context) ReportProgress
Retrieves the progress reporting function from the context
type ReportRead ¶
type ReportWrite ¶
type UnitsReporter ¶
type UnitsReporter struct {
// contains filtered or unexported fields
}
func NewUnitsReporter ¶
func NewUnitsReporter( ctx context.Context, name string, total uint64, ) *UnitsReporter
func (*UnitsReporter) End ¶
func (r *UnitsReporter) End()
func (*UnitsReporter) Report ¶
func (r *UnitsReporter) Report(units uint64, total uint64, err error)
Report the amount of new units progressed, if any, an update to the total value, if any, and an error, if any. Nil-pointer safe
func (*UnitsReporter) Start ¶
func (r *UnitsReporter) Start()
Click to show internal directories.
Click to hide internal directories.