common

package
v0.0.0-...-a0bb070 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccountServer   = "Account"
	ContainerServer = "Container"
	ObjectServer    = "Object"
)

Server Types

View Source
const (
	ONE_WEEK                = 604800
	HASH_FILE               = "hashes.pkl"
	HASH_INVALIDATIONS_FILE = "hashes.invalid"
)

Replcator relative

View Source
const (
	XBackendPolicyIndex        = "X-Backend-Storage-Policy-Index"
	XBackendObjLength          = "X-Backend-Obj-Content-Length"
	XBackendEtagIsAt           = "X-Backend-Etag-Is-At"
	XBackendTimestamp          = "X-Backend-Timestamp"
	XBackendReplicationHeaders = "X-Backend-Replication-Headers"
	XCopyFrom                  = "X-Copy-From"
	XDeleteAtContainer         = "X-Delete-At-Container"
	XDeleteAtPartition         = "X-Delete-At-Partition"
	XDeleteAtHost              = "X-Delete-At-Host"
	XDeleteAtDevice            = "X-Delete-At-Device"
	XAccountHost               = "X-Account-Host"
	XAccountDevice             = "X-Account-Device"
	XAccountPartition          = "X-Account-Partition"

	XContainerHost      = "X-Container-Host"
	XContainerDevice    = "X-Container-Device"
	XContainerPartition = "X-Container-Partition"
	XStaticLargeObject  = "X-Static-Large-Object"
	XObjectManifest     = "X-Object-Manifest"
	XIfDeleteAt         = "X-If-Delete-At"
	XForceAcquire       = "X-Force-Acquire"
	XDiskUsage          = "X-Disk-Usage"
)

Backend header names

View Source
const (
	XStoragePolicy = "X-Storage-Policy"
	XTimestamp     = "X-Timestamp"
	XDeleteAt      = "X-Delete-At"
	XDeleteAfter   = "X-Delete-After"
	XTransId       = "X-Trans-Id"
	XContentType   = "X-Content-Type"
	XSize          = "X-Size"
	XEtag          = "X-ETag"

	IfMatch           = "If-Match"
	IfNoneMatch       = "If-None-Match"
	IfUnmodifiedSince = "If-Unmodified-Since"
	IfModifiedSince   = "If-Modified-Since"

	LastModified = "Last-Modified"
)

Client header names

View Source
const (
	HContentType        = "Content-Type"
	HContentLength      = "Content-Length"
	HExpect             = "Expect"
	HEtag               = "ETag"
	HContentEncoding    = "Content-Encoding"
	HContentDisposition = "Content-Disposition"
	HAcceptRanges       = "Accept-Ranges"
	HRange              = "Range"
	HContentRange       = "Content-Range"
	HReferer            = "Referer"
	HUserAgent          = "User-Agent"

	XContentTypeOptions = "X-Content-Type-Options"
)

Standard header names

View Source
const (
	VOctetStream = "application/octet-stream"
	VTextPlain   = "text/plain"
	V100Continue = "100-Continue"
	VTextHtml    = "text/html; charset=UTF-8"
	VChunked     = "chunked"
	VBytes       = "bytes"
	VNoSniff     = "nosniff"
)

Standard header value

View Source
const (
	REPLICATE = "REPLICATE"
	SYNC      = "SYNC"
)

Non standard Methods

View Source
const (
	ObjectSysMetaPrefix          = "x-object-sysmeta-"
	ObjectTransientSysMetaPrefix = "x-object-transient-sysmeta-"
)

Meta header prefix in lower case

View Source
const (
	StatusClientClosedRequest = 499
	StatusRateLimited         = 488
)

Non standard status code

Variables

View Source
var (
	NotImplementedErr     = errors.New("not implemented yet")
	SuffixNotFoundErr     = errors.New("object suffix not found")
	InvalidPolicyIndexErr = errors.New("invalid storage policy index value")
	PolicyNotFoundErr     = errors.New("policy not found")
	ErrLogConfigNotFound  = errors.New("log configuration not found")
)
View Source
var BootstrapLogger *log.Logger

Log to stdout and rsyslog used during bootstrap.

View Source
var GMT = time.FixedZone("GMT", 0)
View Source
var Version = "0.1"

Functions

func CanonicalTimestamp

func CanonicalTimestamp(t float64) string

func CanonicalTimestampFromTime

func CanonicalTimestampFromTime(t time.Time) string

func CheckNameFormat

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

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 CustomResponse

func CustomResponse(w http.ResponseWriter, statusCode int, message string)

func FormatLastModified

func FormatLastModified(lastModified time.Time) string

func GetDefault

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

func GetEpochFromTimestamp

func GetEpochFromTimestamp(timestamp string) (string, error)

func GetLogger

func GetLogger(conf, name string) (*zap.Logger, error)

func GetTimestamp

func GetTimestamp() string

func GetTransactionId

func GetTransactionId() string

func HashObjectName

func HashObjectName(prefix, account, container, obj, suffix string) string

func HeaderGetDefault

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

func Headers2Map

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

func IsDecimal

func IsDecimal(num string) bool

func IsHex

func IsHex(num string) bool

func IsObjectTransientSysMeta

func IsObjectTransientSysMeta(key string) bool

func IsOriginAllowed

func IsOriginAllowed(allowedOriginHeader, requestOrigin string) bool

func IsSysMeta

func IsSysMeta(server, key string) bool

func IsUserMeta

func IsUserMeta(server, key string) bool

func LooksTrue

func LooksTrue(check string) bool

func Map2Headers

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

func ObjectName

func ObjectName(account, container, obj string) string

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(path 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 RandIntInRange

func RandIntInRange(min, max int) int

func SliceFromCSV

func SliceFromCSV(csv string) []string

func StandardResponse

func StandardResponse(w http.ResponseWriter, statusCode int)

func StandardizeTimestamp

func StandardizeTimestamp(timestamp string) (string, error)

func StatusText

func StatusText(code int) string

func StringInSlice

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

func UUID

func UUID() string

func Urlencode

func Urlencode(str string) string

Types

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 Kmutex

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

func NewKmutex

func NewKmutex() *Kmutex

func (*Kmutex) Lock

func (k *Kmutex) Lock(key interface{})

func (*Kmutex) Unlock

func (k *Kmutex) Unlock(key interface{})

type MultiWriter

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

MultiWriter is a streaming multipart writer, similar to the standar d 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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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