swiftclient

package
v0.0.0-...-653efa9 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package swiftclient provides API access to the local Swift NoAuth Pipeline.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccountDelete

func AccountDelete(accountName string) (err error)

AccountDelete invokes HTTP DELETE on the named Swift Account.

func AccountGet

func AccountGet(accountName string) (headers map[string][]string, containerList []string, err error)

AccountGet invokes HTTP GET on the named Swift Account.

func AccountHead

func AccountHead(accountName string) (headers map[string][]string, err error)

AccountHead invokes HTTP HEAD on the named Swift Account.

func AccountPost

func AccountPost(accountName string, headers map[string][]string) (err error)

AccountPost invokes HTTP POST on the named Swift Account.

func AccountPut

func AccountPut(accountName string, headers map[string][]string) (err error)

AccountPut invokes HTTP PUT on the named Swift Account.

func ChunkedConnectionFreeCnt

func ChunkedConnectionFreeCnt() (freeChunkedConnections int64)

Number of chunked connections that are idle

func ContainerDelete

func ContainerDelete(accountName string, containerName string) (err error)

ContainerDelete invokes HTTP DELETE on the named Swift Container.

func ContainerGet

func ContainerGet(accountName string, containerName string) (headers map[string][]string, objectList []string, err error)

ContainerGet invokes HTTP GET on the named Swift Container.

func ContainerHead

func ContainerHead(accountName string, containerName string) (headers map[string][]string, err error)

ContainerHead invokes HTTP HEAD on the named Swift Container.

func ContainerPost

func ContainerPost(accountName string, containerName string, headers map[string][]string) (err error)

ContainerPost invokes HTTP POST on the named Swift Container.

func ContainerPut

func ContainerPut(accountName string, containerName string, headers map[string][]string) (err error)

ContainerPut invokes HTTP PUT on the named Swift Container.

func NonChunkedConnectionFreeCnt

func NonChunkedConnectionFreeCnt() (freeNonChunkedConnections int64)

Number of non-chunked connections that are idle

func ObjectContentLength

func ObjectContentLength(accountName string, containerName string, objectName string) (length uint64, err error)

ObjectContentLength invokes HTTP HEAD on the named Swift Object and returns value of Content-Length Header.

func ObjectCopy

func ObjectCopy(srcAccountName string, srcContainerName string, srcObjectName string, dstAccountName string, dstContainerName string, dstObjectName string, chunkedCopyContext ChunkedCopyContext) (err error)

ObjectCopy asynchronously creates a copy of the named Swift Object Source called the named Swift Object Destination.

func ObjectDelete

func ObjectDelete(accountName string, containerName string, objectName string, operationOptions OperationOptions) (err error)

ObjectDelete invokes HTTP DELETE on the named Swift Object.

func ObjectGet

func ObjectGet(accountName string, containerName string, objectName string, offset uint64, length uint64) (buf []byte, err error)

ObjectGet invokes HTTP GET on the named Swift Object for the specified byte range.

func ObjectHead

func ObjectHead(accountName string, containerName string, objectName string) (headers map[string][]string, err error)

ObjectHead invokes HTTP HEAD on the named Swift Object.

func ObjectLoad

func ObjectLoad(accountName string, containerName string, objectName string) (buf []byte, err error)

ObjectLoad invokes HTTP GET on the named Swift Object for the entire object.

func ObjectPost

func ObjectPost(accountName string, containerName string, objectName string, headers map[string][]string) (err error)

ObjectPost invokes HTTP POST on the named Swift Object.

func ObjectRead

func ObjectRead(accountName string, containerName string, objectName string, offset uint64, buf []byte) (len uint64, err error)

ObjectRead invokes HTTP GET on the named Swift Object at the specified offset filling in the specified byte slice. Note that the byte slice must already have the desired length even though those bytes will be overwritten.

func ObjectTail

func ObjectTail(accountName string, containerName string, objectName string, length uint64) (buf []byte, err error)

ObjectTail invokes HTTP GET on the named Swift Object with a byte range selecting the specified length of trailing bytes.

func SetStarvationCallbackFunc

func SetStarvationCallbackFunc(starvationCallback StarvationCallbackFunc)

SetStarvationCallbackFunc sets (or resets, if passed nil) the callback function to be invoked when the Chunked PUT Connection Pool is exhausted and would like the callback function to relieve this exhaustion.

Types

type ChunkedCopyContext

type ChunkedCopyContext interface {
	BytesRemaining(bytesRemaining uint64) (chunkSize uint64)
}

ChunkedCopyContext provides a callback context to use for Object Copies.

A returned chunkSize == 0 says to stop copying

type ChunkedPutContext

type ChunkedPutContext interface {
	Active() (active bool)                                     // Report if currently active
	BytesPut() (bytesPut uint64, err error)                    // Report how many bytes have been sent via SendChunk() for this ChunkedPutContext
	Close() (err error)                                        // Finish the "chunked" HTTP PUT for this ChunkedPutContext (with possible retry)
	Read(offset uint64, length uint64) (buf []byte, err error) // Read back bytes previously sent via SendChunk()
	SendChunk(buf []byte) (err error)                          // Send the supplied "chunk" via this ChunkedPutContext
}

ChunkedPutContext provides a context to use for Object HTTP PUTs using "chunked" Transfer-Encoding.

The slice(s) passed to SendChunk() must not be modified until Close() has been called and has returned success or failure. Close() must always be called on a successfullly opened ChunkedPutContext, even if SendChunk() returns an error, or else we will leak open connections (although SendChunk() does its best).

func ObjectFetchChunkedPutContext

func ObjectFetchChunkedPutContext(accountName string, containerName string, objectName string, useReserveForVolumeName string) (chunkedPutContext ChunkedPutContext, err error)

ObjectFetchChunkedPutContext provisions a context to use for an HTTP PUT using "chunked" Transfer-Encoding on the named Swift Object. The useReserveForVolumeName string argument should be set to "" if normal chunked connection pool is to be used. If a reserved connection is to be used, note that there is only one per useReserveForVolumeName allowed at a time.

type OperationOptions

type OperationOptions uint64
const (
	SkipRetry OperationOptions = 1 << iota
)

type RetryCtrl

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

Swift requests should be retried if they fail with a retriable error. RetryCtrl is used to control the retry process, including exponential backoff on subsequent replay attempts. lastReq tracks the time that the last request was made so that time consumed by the request can be subtracted from the backoff amount (if a request takes 30 sec to timeout and the initial delay is 10 sec, we don't want 40 sec between requests).

func NewRetryCtrl

func NewRetryCtrl(maxAttempt uint16, delay time.Duration, expBackoff float64) *RetryCtrl

func (*RetryCtrl) RequestWithRetry

func (this *RetryCtrl) RequestWithRetry(doRequest func() (bool, error), opid *string, reqstat *requestStatistics) (err error)

Perform a request until it suceeds, it fails with an unretriable error, or we hit the maximum retries. doRequest() will issue the request and return both an error indication and a boolean indicating whether the error is retriable or not (if there is an error).

if a request fails, even if this.attemptMax == 0 (retry disabled) this will still log an Error message indicating RequestWithRetry() failed along with the operation identifier (name and paramaters)

func (*RetryCtrl) RetryWait

func (this *RetryCtrl) RetryWait()

Wait until this.delay has elapsed since the last request started and then update the delay with the exponential backoff and record when the next request was started

type StarvationCallbackFunc

type StarvationCallbackFunc func()

StarvationCallbackFunc specifies the signature of a callback function to be invoked when the Chunked PUT Connection Pool is exhausted and would like the callback function to relieve this exhaustion.

type StarvationParameters

type StarvationParameters struct {
	ChunkedConnectionPoolCapacity      uint16
	ChunkedConnectionPoolInUse         uint16
	ChunkedConnectionPoolNumWaiters    uint64
	NonChunkedConnectionPoolCapacity   uint16
	NonChunkedConnectionPoolInUse      uint16
	NonChunkedConnectionPoolNumWaiters uint64
}

StarvationParameters is used to report the current details pertaining to both the chunkedConnectionPool and nonChunkedConnectionPool. As this is a snapshot of a typically rapidly evolving state, it should only be use in well controlled test and debugging situations.

func GetStarvationParameters

func GetStarvationParameters() (starvationParameters *StarvationParameters)

GetStarvationParameters returns the the current details pertaining to both the chunkedConnectionPool and nonChunkedConnectionPool.

Jump to

Keyboard shortcuts

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