cache

package
v0.0.0-...-7220889 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2025 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package cache provides utilities for preforming cache-related operations.

Index

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

func HTTPRequestHeaders(ctx context.Context) map[string]string

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

func RecordCacheAccessFailure(ctx context.Context, sourcePath string, failedHTTPResponseCode int)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL