Documentation
¶
Overview ¶
Package cache provides utilities for preforming cache-related operations.
Index ¶
- func CurlFile(ctx context.Context, run components.Runner, cacheURL, destinationPath string, ...) (int, error)
- func CurlFileContents(ctx context.Context, run components.Runner, cacheURL string, ...) (string, int, error)
- func Extract(ctx context.Context, req *ExtractRequest, run components.Runner) error
- func HTTPRequestHeaders(ctx context.Context) map[string]string
- func RecordCacheAccessFailure(ctx context.Context, sourcePath string, failedHTTPResponseCode int)
- type ExtractRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CurlFile ¶
func CurlFile(ctx context.Context, run components.Runner, cacheURL, destinationPath string, timeout time.Duration) (int, error)
CurlFile downloads file by using curl util.
func CurlFileContents ¶
func CurlFileContents(ctx context.Context, run components.Runner, cacheURL string, timeout time.Duration) (string, int, error)
CurlFileContents reads a file by using curl util.
func Extract ¶
func Extract(ctx context.Context, req *ExtractRequest, run components.Runner) error
Extract extract file from cache service by modifying URL to download the file.
func HTTPRequestHeaders ¶
HTTPRequestHeaders returns a map of header keys to values of HTTP headers that should be included in HTTP requests to the cache service. The values are retrieved from scopes specific to the provided context.
func RecordCacheAccessFailure ¶
RecordCacheAccessFailure records non-500 HTTP response errors of an access attempt of a path as an observation metric.
We are only interested in 500 errors coming from the caching service at the moment, so the observation is only recorded if the code is >= 500. Non-500 errors are recorded by the caching service.
Types ¶
type ExtractRequest ¶
type ExtractRequest struct { // URL to download the file from cache service. CacheFileURL string // Name of the file we wantt o extract from file. ExtractFileName string // Filepath of destination file. DestintionFilePath string // Download timeout. Timeout time.Duration // Number of times the download can be re-attempted. DownloadImageReattemptCount int // Wait before the download is re-attempted. DownloadImageReattemptWait time.Duration }
ExtractRequest holds all data required to extract file from file on cache service.