Documentation
¶
Index ¶
- func CopyFile(src, dst string, perm os.FileMode) error
- func Evict(filePath string) (err error)
- func Fallocate(fd int, size int64) error
- func GetBoolProperty(properties Properties, key string, defaultValue bool) bool
- func GetDurationProperty(properties Properties, key string, defaultValue time.Duration) time.Duration
- func GetFloat64Property(properties Properties, key string, defaultValue float64) float64
- func GetIntProperty(properties Properties, key string, defaultValue int) int
- func GetSortedTimeStamps(destinationFolder string, prefix string, storageHandler StorageHandler) ([]int64, error)
- func GetStringProperty(properties Properties, key string, defaultValue string) string
- func HasProperty(properties Properties, key string) bool
- func ListFetchedFiles(destinationFolder string, basename string, timestamp string, ...) []string
- func ListTempFetchedFiles(destinationFolder string, basename string, storageHandler StorageHandler) []string
- func MMapOptions() int
- func MemoryUnMapAndEvictFile(mmapInfo *MMapInfo)
- func RemoveLastDownloadedFilesAfterError(destinationFolder string, basename string, timestamp string, ...) error
- func RemoveOldFiles(destinationFolder string, basename string, numRetainedDownloads int, ...) error
- func SerializeProperties(properties Properties) string
- func UpdateProperties(properties Properties, arg string) error
- func WriteDecompressedFileToDiskFromReader(f io.Reader, compressedPath string, compressionMethod string, ...) (string, int64, error)
- func WritePropertiesFile(properties Properties, path string) error
- func WriteStringToFile(path string, text string) error
- type CoreDownloader
- type DevNullWriter
- type DownloadError
- type DownloadReason
- type DownloadStats
- type Downloader
- type DownloaderOptions
- type ExtraWriter
- type GCSClient
- type GCSStorageHandler
- type InsertCounter
- type LocalFStorageHandler
- type MMapInfo
- type Properties
- type RemoteSettings
- type StorageHandler
- type WriteCounter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyFile ¶
CopyFile copies the contents from src to dst atomically. If dst does not exist, CopyFile creates it with permissions perm. If the copy fails, CopyFile aborts and dst is preserved.
func GetBoolProperty ¶
func GetBoolProperty(properties Properties, key string, defaultValue bool) bool
func GetDurationProperty ¶
func GetFloat64Property ¶
func GetFloat64Property(properties Properties, key string, defaultValue float64) float64
func GetIntProperty ¶
func GetIntProperty(properties Properties, key string, defaultValue int) int
func GetSortedTimeStamps ¶
func GetSortedTimeStamps(destinationFolder string, prefix string, storageHandler StorageHandler) ([]int64, error)
func GetStringProperty ¶
func GetStringProperty(properties Properties, key string, defaultValue string) string
func HasProperty ¶
func HasProperty(properties Properties, key string) bool
func ListFetchedFiles ¶
func ListFetchedFiles(destinationFolder string, basename string, timestamp string, storageHandler StorageHandler) []string
func ListTempFetchedFiles ¶
func ListTempFetchedFiles(destinationFolder string, basename string, storageHandler StorageHandler) []string
func MMapOptions ¶
func MMapOptions() int
func MemoryUnMapAndEvictFile ¶
func MemoryUnMapAndEvictFile(mmapInfo *MMapInfo)
func RemoveLastDownloadedFilesAfterError ¶
func RemoveLastDownloadedFilesAfterError(destinationFolder string, basename string, timestamp string, storageHandler StorageHandler) error
func RemoveOldFiles ¶
func SerializeProperties ¶
func SerializeProperties(properties Properties) string
func UpdateProperties ¶
func UpdateProperties(properties Properties, arg string) error
func WritePropertiesFile ¶
func WritePropertiesFile(properties Properties, path string) error
func WriteStringToFile ¶
Types ¶
type CoreDownloader ¶
func MakeHttpClient ¶
func MakeHttpClient(downloaderOptions *DownloaderOptions, baseUrls []string, useTimeout bool) (CoreDownloader, error)
type DevNullWriter ¶
type DevNullWriter struct {
}
func (*DevNullWriter) GetTotalRows ¶
func (d *DevNullWriter) GetTotalRows() int
type DownloadError ¶
func (*DownloadError) Error ¶
func (e *DownloadError) Error() string
type DownloadReason ¶
type DownloadReason int
The String() function below needs to be updated when adding entries
const ( UpToDate DownloadReason = iota // 0 NoTimestamp // 1 MissingLatestTimestamp // 2 MissingRemoteInputs // 3 MissingLocalInputs // 4 EmptyRemoteInputs // 5 EmptyLocalInputs // 6 SimilarRemoteAndLocalInputs // 7 DifferentRemoteAndLocalInputs // 8 NotEnoughFiles // 9 )
func (DownloadReason) String ¶
func (reason DownloadReason) String() string
type DownloadStats ¶
type DownloadStats struct {
Timestamp string `json:"timestamp"`
Delay string `json:"delay"`
DownloadMethod string `json:"download_method"`
Prefetch string `json:"pre_fetch"`
Download string `json:"download"`
DownloadSeconds float64 `json:"download_seconds"`
DownloadSpeed string `json:"download_speed"`
DiskWrite string `json:"decompress_checksum_disk_write"`
DiskWriteSeconds float64 `json:"decompress_checksum_disk_write_seconds"`
MMap string `json:"mmap"`
MMapSeconds float64 `json:"mmap_seconds"`
Total string `json:"total"`
TotalSeconds float64 `json:"total_seconds"`
CompressedSize string `json:"compressed_size"`
CompressedPath string `json:"compressed_path"`
DecompressedSize string `json:"decompressed_size"`
DecompressedSizeInBytes int64 `json:"decompressed_size_bytes"`
DecompressedPath string `json:"decompressed_path"`
BaseUrl string `json:"base_url"`
TotalBytesDownloaded int64 `json:"total_bytes_downloaded"`
TotalBytesWrittenToDisk int64 `json:"total_bytes_written_to_disk"`
TotalRows int `json:"total_rows"`
SavedFiles []string `json:"saved_files"`
}
type Downloader ¶
type Downloader struct {
Basename string
BasenameNoExt string
DestinationFolder string
AllUrls string
DownloadMethod string
Log *logrus.Entry
MMapInfo *MMapInfo
RemoteSettings RemoteSettings
// Clients used to be *http.Client before GCS support
HttpClient CoreDownloader
HttpClientNoTimeout CoreDownloader
// Bail out after a certain amount of time.
NoProgressTimeout int
DefaultCompressionMethod string
DefaultChecksumExtension string
// Memory map a file after download, so that it is ready and fully loaded in memory for
// servers to utilize it right away. We do this in process with ccache V2, so this is only
// enabled for ccache V1 files
MMapFileAfterDownload bool
}
func NewDownloader ¶
func NewDownloader(downloaderOptions *DownloaderOptions) *Downloader
func (*Downloader) DownloadFile ¶
func (d *Downloader) DownloadFile(filepath string, url string) error
DownloadFile will download a url to a local file. It's efficient because it will write as it downloads and not load the whole file into memory. We pass an io.TeeReader into Copy() to report progress on the download.
func (*Downloader) GetBaseUrlAndTimestamp ¶
func (d *Downloader) GetBaseUrlAndTimestamp() (string, string, error)
func (*Downloader) Run ¶
func (d *Downloader) Run() (DownloadStats, error)
type DownloaderOptions ¶
type GCSClient ¶
func NewGCSClient ¶
type GCSStorageHandler ¶
GCS
func (*GCSStorageHandler) CopyFile ¶
func (g *GCSStorageHandler) CopyFile(src, dst string, perm os.FileMode) error
func (*GCSStorageHandler) Remove ¶
func (g *GCSStorageHandler) Remove(file string) error
type InsertCounter ¶
type InsertCounter struct {
Label string
Start time.Time
Total int64
LastTotal int64
Mutex sync.Mutex
}
func (*InsertCounter) Incr ¶
func (ic *InsertCounter) Incr()
func (*InsertCounter) SetLabel ¶
func (ic *InsertCounter) SetLabel(label string)
type LocalFStorageHandler ¶
type LocalFStorageHandler struct {
}
Local filesystem
func (*LocalFStorageHandler) CopyFile ¶
func (l *LocalFStorageHandler) CopyFile(src, dst string, perm os.FileMode) error
func (*LocalFStorageHandler) Glob ¶
func (l *LocalFStorageHandler) Glob(pattern string) ([]string, error)
func (*LocalFStorageHandler) Remove ¶
func (l *LocalFStorageHandler) Remove(file string) error
type MMapInfo ¶
func MemoryMapFile ¶
type Properties ¶
func LoadPropertiesFile ¶
func LoadPropertiesFile(path string) (Properties, error)
type RemoteSettings ¶
type RemoteSettings struct {
// contains filtered or unexported fields
}
type StorageHandler ¶
type StorageHandler interface {
// Need to copy files over
CopyFile(src, dst string, perm os.FileMode) error
// Need to do directory listing remotely
Glob(pattern string) ([]string, error)
// So that we can remove some files (typically the old ones)
Remove(file string) error
}
Those are the basic operations that are needed to manage files pushed to GCS (or a mirror).
func MakeStorageHandler ¶
func MakeStorageHandler(path string) StorageHandler
Utility code to make a storage handler
type WriteCounter ¶
type WriteCounter struct {
Label string
Total uint64
ContentLength int64
Name string
Start time.Time
LastTotal uint64
}
WriteCounter counts the number of bytes written to it. It implements to the io.Writer interface and we can pass this into io.TeeReader() which will report progress on each write cycle.