fetch

package
v0.0.0-...-4926e8e Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// QualifierLegacyBazelHTTPHeaders is the qualifier older versions of bazel sends.
	QualifierLegacyBazelHTTPHeaders = "bazel.auth_headers"
	// QualifierHTTPHeaderPrefix is a qualifer to add a header to all URIs.
	// Qualifier will be in the form http_header:<header>
	QualifierHTTPHeaderPrefix = "http_header:"
	// QualifierHTTPHeaderURLPrefix is a qualifier to add a header to a specific URI.
	// Qualifier will be in the form http_header_url:<index>:<header>
	QualifierHTTPHeaderURLPrefix = "http_header_url:"
)

Variables

View Source
var DefaultFetcher = NewErrorFetcher(&protostatus.Status{Code: 12, Message: "Fetching is not configured for this server"})

DefaultFetcher returns a NotImplemented error and a message that fetching is not configured

Functions

This section is empty.

Types

type AuthHeaders

type AuthHeaders map[string]map[string]string

AuthHeaders is a map from target URI to headers to be applied for the request

func NewAuthHeaders

func NewAuthHeaders() *AuthHeaders

NewAuthHeaders creates an empty AuthHeaders

func NewAuthHeadersFromQualifier

func NewAuthHeadersFromQualifier(value string) (*AuthHeaders, error)

NewAuthHeadersFromQualifier creates an AuthHeaders from the qualifier payload

func (AuthHeaders) AddHeader

func (ah AuthHeaders) AddHeader(uri, header, value string)

AddHeader adds a header to the AuthHeaders

func (AuthHeaders) ApplyHeaders

func (ah AuthHeaders) ApplyHeaders(uri string, req *http.Request)

ApplyHeaders mutates a http.Request to apply headers requested by the client.

type AuthorizingFetcher

type AuthorizingFetcher struct {
	Fetcher
	// contains filtered or unexported fields
}

AuthorizingFetcher decorates Fetcher and validates the requests against an Authorizer

func NewAuthorizingFetcher

func NewAuthorizingFetcher(f Fetcher, authorizer auth.Authorizer) *AuthorizingFetcher

NewAuthorizingFetcher creates a new AuthorizingFetcher

func (*AuthorizingFetcher) FetchBlob

FetchBlob wraps FetchBlob requests, validate request against authorizer

func (*AuthorizingFetcher) FetchDirectory

FetchDirectory wraps FetchDirectory requests, validate request against authorizer

type Fetcher

type Fetcher interface {
	// The same as a Remote Asset API FetchBlob request
	FetchBlob(context.Context, *remoteasset.FetchBlobRequest) (*remoteasset.FetchBlobResponse, error)

	// The same as a Remote Asset API FetchDirectory request
	FetchDirectory(context.Context, *remoteasset.FetchDirectoryRequest) (*remoteasset.FetchDirectoryResponse, error)

	// Check for unsupported Qualifiers, returning a set of the _unsupported_ qualifiers
	CheckQualifiers(qualifier.Set) qualifier.Set
}

Fetcher is an abstraction around a Remote Asset API Fetch Server to allow for more consistent Qualifier usage.

func NewCachingFetcher

func NewCachingFetcher(fetcher Fetcher, assetStore storage.AssetStore) Fetcher

NewCachingFetcher creates a decorator for remoteasset.FetchServer implementations to avoid having to fetch the blob remotely multiple times

func NewErrorFetcher

func NewErrorFetcher(err *protostatus.Status) Fetcher

NewErrorFetcher creates a Remote Asset API Fetch service which simply returns a set gRPC status

func NewHTTPFetcher

func NewHTTPFetcher(httpClient *http.Client,
	contentAddressableStorage blobstore.BlobAccess,
) Fetcher

NewHTTPFetcher creates a remoteasset FetchServer compatible service for handling requests which involve downloading assets over HTTP and storing them into a CAS.

func NewLoggingFetcher

func NewLoggingFetcher(fetcher Fetcher) Fetcher

NewLoggingFetcher creates a fetcher which logs requests and results

func NewMetricsFetcher

func NewMetricsFetcher(fetcher Fetcher, clock clock.Clock, name string) Fetcher

NewMetricsFetcher creates a fetcher which logs metrics to prometheus

func NewRemoteExecutionFetcher

func NewRemoteExecutionFetcher(contentAddressableStorage blobstore.BlobAccess, client grpc.ClientConnInterface, maximumMessageSizeBytes int) Fetcher

NewRemoteExecutionFetcher creates a new Fetcher that is capable of itself fetching resources from other places (as defined in the qualifier_translator).

func NewValidatingFetcher

func NewValidatingFetcher(fetcher Fetcher) Fetcher

NewValidatingFetcher creates a fetcher that validates Fetch* requests are valid, before passing on to a backend

Jump to

Keyboard shortcuts

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