Functions
Close
method
#
Close cleans up any resources associated with the uploader.
func (u *uploader) Close() error
Run
function
#
Run generates and uploads reports, as allowed by the mode file.
func Run(config RunConfig) error
Run
method
#
Run generates and uploads reports
func (u *uploader) Run() error
computeRandom
function
#
computeRandom returns a cryptographic random float64 in the range [0, 1],
with 52 bits of precision.
func computeRandom() float64
counterDateSpan
method
#
counterDateSpan parses the counter file named fname and returns the (begin,
end) span recorded in its metadata, or an error if this data could not be
extracted.
func (u *uploader) counterDateSpan(fname string) (begin time.Time, end time.Time, _ error)
createReport
method
#
createReport creates local and upload report files by
combining all the count files for the expiryDate, and
returns the upload report file's path.
It may delete the count files once local and upload report
files are successfully created.
func (u *uploader) createReport(start time.Time, expiryDate string, countFiles []string, lastWeek string) (string, error)
debugLogFile
function
#
debugLogFile arranges to write a log file in the given debug directory, if
it exists.
func debugLogFile(debugDir string) (*os.File, error)
deleteFiles
method
#
func (u *uploader) deleteFiles(files []string)
exclusiveWrite
function
#
exclusiveWrite attempts to create filename exclusively, and if successful,
writes content to the resulting file handle.
It returns a boolean indicating whether the exclusive handle was acquired,
and an error indicating whether the operation succeeded.
If the file already exists, exclusiveWrite returns (false, nil).
func exclusiveWrite(filename string, content []byte) (_ bool, rerr error)
findProgReport
function
#
return an existing ProgremReport, or create anew
func findProgReport(meta map[string]string, report *telemetry.Report) *telemetry.ProgramReport
findWork
method
#
find all the files that look like counter files or reports
that need to be uploaded. (There may be unexpected leftover files
and uploading is supposed to be idempotent.)
func (u *uploader) findWork() work
latestReport
function
#
latestReport returns the YYYY-MM-DD of the last report uploaded
or the empty string if there are no reports.
func latestReport(uploaded map[string]bool) string
newUploader
function
#
newUploader creates a new uploader to use for running the upload for the
given config.
Uploaders should only be used for one call to [uploader.Run].
func newUploader(rcfg RunConfig) (*uploader, error)
notNeeded
function
#
notNeeded returns true if the report for date has already been created
func notNeeded(date string, todo work) bool
parseCountFile
method
#
func (u *uploader) parseCountFile(fname string) (*counter.File, error)
reports
method
#
reports generates reports from inactive count files
func (u *uploader) reports(todo *work) ([]string, error)
tooOld
method
#
reports that are too old (21 days) are not uploaded
func (u *uploader) tooOld(date string, uploadStartTime time.Time) bool
uploadReport
method
#
func (u *uploader) uploadReport(fname string)
uploadReportContents
method
#
try to upload the report, 'true' if successful
func (u *uploader) uploadReportContents(fname string, buf []byte) bool
uploadReportDate
method
#
uploadReportDate returns the date component of the upload file name, or "" if the
date was unmatched.
func (u *uploader) uploadReportDate(fname string) time.Time