common

package
v0.0.0-...-2f3b49c Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2018 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_FILE_SIZE             = int64(5368709122)
	MAX_META_NAME_LENGTH      = 128
	MAX_META_VALUE_LENGTH     = 256
	MAX_META_COUNT            = 90
	MAX_META_OVERALL_SIZE     = 4096
	MAX_HEADER_SIZE           = 8192
	MAX_OBJECT_NAME_LENGTH    = 1024
	CONTAINER_LISTING_LIMIT   = 10000
	ACCOUNT_LISTING_LIMIT     = 10000
	MAX_ACCOUNT_NAME_LENGTH   = 256
	MAX_CONTAINER_NAME_LENGTH = 256
	EXTRA_HEADER_COUNT        = 0
)
View Source
const (
	DefaultProxyServerPort         = 8080
	DefaultAndrewdPort             = 6003
	DefaultAccountServerPort       = 6002
	DefaultAccountReplicatorPort   = DefaultAccountServerPort + 500
	DefaultContainerServerPort     = 6001
	DefaultContainerReplicatorPort = DefaultContainerServerPort + 500
	DefaultObjectServerPort        = 6000
	DefaultObjectReplicatorPort    = DefaultObjectServerPort + 500
)
View Source
const ONE_DAY = 86400
View Source
const ONE_WEEK = 604800
View Source
const SWIFT_OBJECT_METADATA_CHUNK_SIZE = 65536

Variables

View Source
var DEFAULT_CONSTRAINTS = map[string]interface{}{
	"max_file_size":             MAX_FILE_SIZE,
	"max_meta_name_length":      MAX_META_NAME_LENGTH,
	"max_meta_value_length":     MAX_META_VALUE_LENGTH,
	"max_meta_count":            MAX_META_COUNT,
	"max_meta_overall_size":     MAX_META_OVERALL_SIZE,
	"max_header_size":           MAX_HEADER_SIZE,
	"max_object_name_length":    MAX_OBJECT_NAME_LENGTH,
	"container_listing_limit":   CONTAINER_LISTING_LIMIT,
	"account_listing_limit":     ACCOUNT_LISTING_LIMIT,
	"max_account_name_length":   MAX_ACCOUNT_NAME_LENGTH,
	"max_container_name_length": MAX_CONTAINER_NAME_LENGTH,
	"extra_header_count":        EXTRA_HEADER_COUNT,
}
View Source
var GMT = time.FixedZone("GMT", 0)
View Source
var OwnerHeaders = map[string]bool{
	"x-container-read":                true,
	"x-container-write":               true,
	"x-container-sync-key":            true,
	"x-container-sync-to":             true,
	"x-account-meta-temp-url-key":     true,
	"x-account-meta-temp-url-key-2":   true,
	"x-container-meta-temp-url-key":   true,
	"x-container-meta-temp-url-key-2": true,
	"x-account-access-control":        true,
}
View Source
var Version = "0.1"

Functions

func CanonicalTimestamp

func CanonicalTimestamp(t float64) string

func CanonicalTimestampFromTime

func CanonicalTimestampFromTime(t time.Time) string

func CheckContainerPut

func CheckContainerPut(req *http.Request, containerName string) (int, string)

func CheckMetadata

func CheckMetadata(req *http.Request, targetType string) (int, string)

func CheckNameFormat

func CheckNameFormat(req *http.Request, name string, target string) (string, error)

func CheckObjPost

func CheckObjPost(req *http.Request, objectName string) (int, string)

func CheckObjPut

func CheckObjPut(req *http.Request, objectName string) (int, string)

func Copy

func Copy(src io.Reader, dsts ...io.Writer) (written int64, err error)

func CopyN

func CopyN(src io.Reader, n int64, dsts ...io.Writer) (written int64, err error)

func CopyQuorum

func CopyQuorum(src io.Reader, quorum int, dsts ...io.Writer) (int64, error)

CopyQuorum copies data from src to dsts. It behaves mostly like a Copy to a MultiWriter, but it doesn't return an error when a single dst has a write error, only after the number of working dsts drops below quorum.

func FileMD5

func FileMD5(files ...string) (map[string]string, error)

func FormatLastModified

func FormatLastModified(lastModified time.Time) string

func GetAllRingFileMd5s

func GetAllRingFileMd5s() (map[string]string, error)

func GetDefault

func GetDefault(h http.Header, key string, dfl string) string

func GetEpochFromTimestamp

func GetEpochFromTimestamp(timestamp string) (string, error)

func GetTimestamp

func GetTimestamp() string

func GetTransactionId

func GetTransactionId() string

func HeaderGetDefault

func HeaderGetDefault(h http.Header, key string, dfl string) string

func Headers2Map

func Headers2Map(headers http.Header) map[string]string

func IsCorruptDBError

func IsCorruptDBError(err error) bool

func IsOriginAllowed

func IsOriginAllowed(allowedOriginHeader, requestOrigin string) bool

func LooksTrue

func LooksTrue(check string) bool

func Map2Headers

func Map2Headers(m map[string]string) http.Header

func NewClientTLSConfig

func NewClientTLSConfig(certFile, keyFile string) (*tls.Config, error)

func NewTestScope

func NewTestScope() *testScope

func ParseContentTypeForSlo

func ParseContentTypeForSlo(contentType string, listedSize int64) (string, int64, error)

func ParseDate

func ParseDate(date string) (time.Time, error)

func ParseIfMatch

func ParseIfMatch(s string) map[string]bool

func ParseProxyPath

func ParseProxyPath(pth string) (pathMap map[string]string, err error)

will split out url path the proxy would receive and return map with keys: "vrs", "account", "container", "object"

func QuarantineDir

func QuarantineDir(dirPath string, dirDepth int, dirType string) error

func SliceFromCSV

func SliceFromCSV(csv string) []string

func StandardizeTimestamp

func StandardizeTimestamp(timestamp string) (string, error)

func StringInSlice

func StringInSlice(s string, slice []string) bool

func StringInSliceIndex

func StringInSliceIndex(s string, slice []string) int

func SwiftObjectRawReadMetadata

func SwiftObjectRawReadMetadata(fileNameOrFd interface{}) ([]byte, error)

func SwiftObjectRawWriteMetadata

func SwiftObjectRawWriteMetadata(fd uintptr, buf []byte) error

func SwiftObjectReadMetadata

func SwiftObjectReadMetadata(fileNameOrFd interface{}) (map[string]string, error)

func SwiftObjectWriteMetadata

func SwiftObjectWriteMetadata(fd uintptr, v map[string]string) error

func UUID

func UUID() string

func Urlencode

func Urlencode(str string) string

Types

type Expector

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

Expector helps organize a group of "Expect: 100-continue" requests. It attempts to get all requests to a state where they've either given a non-100 response or they are ready to receive upload bodies.

func NewExpector

func NewExpector(client *http.Client) *Expector

NewExpector returns an Expector object that uses the given http client.

func (*Expector) AddRequest

func (e *Expector) AddRequest(req *http.Request)

AddRequest begins an http.Request and adds it to the set of requests being tracked by the Expector.

func (*Expector) Close

func (e *Expector) Close()

Closes responses bodies and attempts to cancel any outstanding requests by returning an error on read from their Body.

func (*Expector) Successes

func (e *Expector) Successes(timeout time.Duration, notFoundOk bool) (count int)

Successes waits up to timeout time for all of the Expector's requests to return a response, then returns the number that successfully responded with a 2XX response code.

func (*Expector) Wait

func (e *Expector) Wait(timeout time.Duration) ([]*http.Response, []bool)

Wait waits up to timeout time for all of the Expector's requests to either be ready or have a response. It returns slices of responses (with nil responses for any requests that haven't received a response) and boolean "ready" states indicating if they are waiting to read from their Body.

type FreePool

type FreePool []*unsafe.Pointer

func NewFreePool

func NewFreePool(size int) FreePool

func (FreePool) Get

func (a FreePool) Get() interface{}

func (FreePool) Put

func (a FreePool) Put(v interface{})

type HttpRange

type HttpRange struct {
	Start, End int64
}

func ParseRange

func ParseRange(rangeHeader string, fileSize int64) (reqRanges []HttpRange, err error)

type KeyedLimit

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

More like a map of semaphores. I don't know what to call it.

func NewKeyedLimit

func NewKeyedLimit(limitPerKey int64, totalLimit int64) *KeyedLimit

func (*KeyedLimit) Acquire

func (k *KeyedLimit) Acquire(key string, force bool) int64

func (*KeyedLimit) Keys

func (k *KeyedLimit) Keys() []string

func (*KeyedLimit) Lock

func (k *KeyedLimit) Lock(key string)

func (*KeyedLimit) MarshalJSON

func (k *KeyedLimit) MarshalJSON() ([]byte, error)

func (*KeyedLimit) Release

func (k *KeyedLimit) Release(key string)

func (*KeyedLimit) Unlock

func (k *KeyedLimit) Unlock(key string)

type MultiWriter

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

MultiWriter is a streaming multipart writer, similar to the standard library's multipart.Writer, but compatible with Swift's output and with an API geared toward our common use, multi-range responses.

func NewMultiWriter

func NewMultiWriter(w io.Writer, contentType string, contentLength int64) *MultiWriter

NewMultiWriter instantiates a new MultiWriter.

func (*MultiWriter) Boundary

func (w *MultiWriter) Boundary() string

Boundary returns the MultiWriter's boundary string.

func (*MultiWriter) Close

func (w *MultiWriter) Close() error

Close finalizes the output of the MultiWriter.

func (*MultiWriter) ContentLength

func (w *MultiWriter) ContentLength() int64

ContentLength returns the expected Content-Length of the multipart body.

func (*MultiWriter) CreatePart

func (w *MultiWriter) CreatePart(start, end int64) (io.Writer, error)

CreatePart begins a new part in the multi-part response, with the given content ranges.

func (*MultiWriter) Expect

func (w *MultiWriter) Expect(start, end int64)

Expect adds an expected part to the Content-Length estimate for the multipart body.

type TestCounter

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

func (*TestCounter) Inc

func (c *TestCounter) Inc(delta int64)

func (*TestCounter) Value

func (c *TestCounter) Value() int64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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