client

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Overview

**************************************************************

*
* Copyright (C) 2023, University of Nebraska-Lincoln
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License.  You may
* obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**************************************************************

Index

Constants

This section is empty.

Variables

View Source
var CacheOverride bool

CacheOverride

View Source
var CachesJsonLocation string
View Source
var CachesToTry int = 3

Number of caches to attempt to use in any invocation

View Source
var NearestCache string

Nearest cache

View Source
var NearestCacheList []string

List of caches, in order from closest to furthest

View Source
var UploadClient = &http.Client{Transport: config.GetTransport()}

Functions

func AcquireToken

func AcquireToken(destination *url.URL, namespace namespaces.Namespace, opts config.TokenGenerationOpts) (string, error)

Given a URL and a piece of the namespace, attempt to acquire a valid token for that URL.

func AddError

func AddError(err error) bool

AddError will add an accumulated error to the error stack

func ByteCountSI

func ByteCountSI(b int64) string

func CanDisableProxy

func CanDisableProxy() bool

Determine whether we are allowed to skip the proxy as a fallback

func CheckOSDF

func CheckOSDF(destination string, methods []string) (remoteSize uint64, err error)

Check the size of a remote file in an origin

func ClearErrors

func ClearErrors()

func CreateNsFromDirectorResp

func CreateNsFromDirectorResp(dirResp *http.Response) (namespace namespaces.Namespace, err error)

Given the Director response, create the ordered list of caches and store it as namespace.SortedDirectorCaches

func CreateSharingUrl

func CreateSharingUrl(objectUrl *url.URL, isWrite bool) (string, error)

func DoShadowIngest

func DoShadowIngest(sourceFile string, originPrefix string, shadowOriginPrefix string) (int64, string, error)

func DoStashCPSingle

func DoStashCPSingle(sourceFile string, destination string, methods []string, recursive bool) (bytesTransferred int64, err error)

Start the transfer, whether read or write back

func DownloadHTTP

func DownloadHTTP(transfer TransferDetails, dest string, token string) (int64, error)

DownloadHTTP - Perform the actual download of the file

func ErrorsRetryable

func ErrorsRetryable() bool

ErrorsRetryable returns if the errors in the stack are retryable later

func Find

func Find(slice []string, val string) (int, bool)

Find takes a slice and looks for an element in it. If found it will return it's key, otherwise it will return -1 and a bool of false. From https://golangcode.com/check-if-element-exists-in-slice/

func GetBehavior

func GetBehavior(behaviorName string) (packerBehavior, error)

func GetBestCache

func GetBestCache(cacheListName string) ([]string, error)

func GetCacheHostnames

func GetCacheHostnames(testFile string) (urls []string, err error)

FIXME: GetCacheHostnames is not director-aware!

func GetCachesFromDirectorResponse

func GetCachesFromDirectorResponse(resp *http.Response, needsToken bool) (caches []namespaces.DirectorCache, err error)

func GetErrors

func GetErrors() string

func HasPort

func HasPort(host string) bool

HasPort test the host if it includes a port

func HeaderParser

func HeaderParser(values string) (retMap map[string]string)

Simple parser to that takes a "values" string from a header and turns it into a map of key/value pairs

func IsProxyEnabled

func IsProxyEnabled() bool

Determines whether or not we can interact with the site HTTP proxy

func IsRetryable

func IsRetryable(err error) bool

IsRetryable will return true if the error is retryable

func QueryDirector

func QueryDirector(source string, directorUrl string) (resp *http.Response, err error)

func RegisterClient

func RegisterClient(namespace namespaces.Namespace) (*config.PrefixEntry, error)

func StatHttp

func StatHttp(dest *url.URL, namespace namespaces.Namespace) (uint64, error)

func TokenIsAcceptable

func TokenIsAcceptable(jwtSerialized string, osdfPath string, namespace namespaces.Namespace, opts config.TokenGenerationOpts) bool

func TokenIsExpired

func TokenIsExpired(jwtSerialized string) bool

func UploadDirectory

func UploadDirectory(src string, dest *url.URL, token string, namespace namespaces.Namespace) (int64, error)

Recursively uploads a directory with all files and nested dirs, keeping file structure on server side

func UploadFile

func UploadFile(src string, origDest *url.URL, token string, namespace namespaces.Namespace) (int64, error)

UploadFile Uploads a file using HTTP

Types

type CacheInterface

type CacheInterface interface{}

func GetCachesFromNamespace

func GetCachesFromNamespace(namespace namespaces.Namespace, useDirector bool) (caches []CacheInterface, err error)

type ConnectionSetupError

type ConnectionSetupError struct {
	URL string
	Err error
}

ConnectionSetupError is an error that is returned when a connection to the remote server fails

func (*ConnectionSetupError) Error

func (e *ConnectionSetupError) Error() string

func (*ConnectionSetupError) Is

func (e *ConnectionSetupError) Is(target error) bool

func (*ConnectionSetupError) Unwrap

func (e *ConnectionSetupError) Unwrap() error

type ConstantSizer

type ConstantSizer struct {
	// contains filtered or unexported fields
}

func (*ConstantSizer) BytesComplete

func (cs *ConstantSizer) BytesComplete() int64

func (*ConstantSizer) Size

func (cs *ConstantSizer) Size() int64

type FileDownloadError

type FileDownloadError struct {
	Text string
	Err  error
}

func (*FileDownloadError) Error

func (e *FileDownloadError) Error() string

func (*FileDownloadError) Unwrap

func (e *FileDownloadError) Unwrap() error

type HttpErrResp

type HttpErrResp struct {
	Code int
	Err  string
}

func (*HttpErrResp) Error

func (e *HttpErrResp) Error() string

type OptionsStruct

type OptionsStruct struct {
	ProgressBars bool
	Recursive    bool
	Plugin       bool
	Token        string
	Version      string
}
var ObjectClientOptions OptionsStruct

type ProgressReader

type ProgressReader struct {
	// contains filtered or unexported fields
}

ProgressReader wraps the io.Reader to get progress Adapted from https://stackoverflow.com/questions/26050380/go-tracking-post-request-progress

func (*ProgressReader) BytesComplete

func (pr *ProgressReader) BytesComplete() int64

func (*ProgressReader) Close

func (pr *ProgressReader) Close() error

Close implments the close function of io.Closer

func (*ProgressReader) Read

func (pr *ProgressReader) Read(p []byte) (n int, err error)

Read implements the common read function for io.Reader

func (*ProgressReader) Size

func (pr *ProgressReader) Size() int64

type Sizer

type Sizer interface {
	Size() int64
	BytesComplete() int64
}

type SlowTransferError

type SlowTransferError struct {
	BytesTransferred int64
	BytesPerSecond   int64
	BytesTotal       int64
	Duration         time.Duration
}

SlowTransferError is an error that is returned when a transfer takes longer than the configured timeout

func (*SlowTransferError) Error

func (e *SlowTransferError) Error() string

func (*SlowTransferError) Is

func (e *SlowTransferError) Is(target error) bool

type StoppedTransferError

type StoppedTransferError struct {
	Err string
}

func (*StoppedTransferError) Error

func (e *StoppedTransferError) Error() string

type TimestampedError

type TimestampedError struct {
	// contains filtered or unexported fields
}

type TransferDetails

type TransferDetails struct {
	// Url is the url.URL of the cache and port
	Url url.URL

	// Proxy specifies if a proxy should be used
	Proxy bool

	// Specifies the pack option in the transfer URL
	PackOption string
}

func GenerateTransferDetailsUsingCache

func GenerateTransferDetailsUsingCache(cache CacheInterface, opts TransferDetailsOptions) []TransferDetails

func NewTransferDetails

func NewTransferDetails(cache namespaces.Cache, opts TransferDetailsOptions) []TransferDetails

NewTransferDetails creates the TransferDetails struct with the given cache

func NewTransferDetailsUsingDirector

func NewTransferDetailsUsingDirector(cache namespaces.DirectorCache, opts TransferDetailsOptions) []TransferDetails

NewTransferDetails creates the TransferDetails struct with the given cache

type TransferDetailsOptions

type TransferDetailsOptions struct {
	NeedsToken bool
	PackOption string
}

type TransferResults

type TransferResults struct {
	Error      error
	Downloaded int64
}

Jump to

Keyboard shortcuts

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