objval

package
v5.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package objval provides types/definitions used by 'objstore'.

Index

Constants

This section is empty.

Variables

View Source
var ErrByteRangeRequired = errors.New("a byte range is required but hasn't been provided")

ErrByteRangeRequired is returned when a function which requires a byte range hasn't been provided with one.

Functions

This section is empty.

Types

type ByteRange

type ByteRange struct {
	Start int64
	End   int64
}

ByteRange represents a byte range of an object in the HTTP range header format. For more information on the format see 'https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35'.

func (*ByteRange) ToOffsetLength

func (b *ByteRange) ToOffsetLength(length int64) (int64, int64)

ToOffsetLength returns the offset/length representation of this byte range.

func (*ByteRange) ToRangeHeader

func (b *ByteRange) ToRangeHeader() string

ToRangeHeader returns the HTTP range header representation of this byte range.

func (*ByteRange) Valid

func (b *ByteRange) Valid(required bool) error

Valid returns an error if the byte range is invalid, <nil> otherwise.

type InvalidByteRangeError

type InvalidByteRangeError struct {
	ByteRange *ByteRange
}

InvalidByteRangeError is returned if a byte range is invalid for some reason.

func (*InvalidByteRangeError) Error

func (e *InvalidByteRangeError) Error() string

Error implements the 'error' interface.

type Object

type Object struct {
	ObjectAttrs

	// This body will generally be a HTTP response body; it should be read once, and closed to avoid resource leaks.
	//
	// NOTE: Depending on the request type, this may not be the entire body of the object, just a byte range.
	Body io.ReadCloser
}

Object represents an object stored in the cloud, simply the attributes and it's body.

type ObjectAttrs

type ObjectAttrs struct {
	// Key is the identifier for the object; a unique path.
	Key string

	// Version is the unique version of the object. This is optional.
	Version any

	// ETag is the HTTP entity tag for the object, each cloud provider uses this differently with different rules also
	// applying to different scenarios (e.g. multipart uploads).
	//
	// NOTE: Not populated during object iteration.
	ETag *string

	// Size is the size or content length of the object in bytes.
	//
	// NOTE: May be conditionally populated by 'GetObject', for example when a chunked response is returned, this
	// attribute will be <nil>.
	Size *int64

	// LastModified is the time the object was last updated (or created).
	//
	// NOTE: The semantics of this attribute may differ between cloud providers (e.g. an change of metadata might bump
	// the last modified time).
	LastModified *time.Time
}

ObjectAttrs represents the attributes usually attached to an object in the cloud.

func (*ObjectAttrs) IsDir

func (o *ObjectAttrs) IsDir() bool

IsDir returns a boolean indicating whether these attributes represent a synthetic directory, created by the library when iterating objects using a 'delimiter'. When 'IsDir' returns 'true', only the 'Key' attribute will be populated.

NOTE: This does not, and will not indicate whether the remote object is itself a directory stub; a zero length object created by the AWS WebUI.

type Part

type Part struct {
	// ID is a unique identifier, which is used by each client when completing the multipart upload; this will be an
	// entity tag for some clients, and a generated key for others.
	ID string

	// Number is a number between 1-10,000 which can be used for ordering parts when a multipart upload is completed.
	//
	// NOTE: This field will not be populated in functions which fetch a list of parts from remote cloud providers.
	Number int

	// Size is the size of the part in bytes.
	Size int64
}

Part represents the metadata from a single part from a multipart upload.

func (Part) Equal

func (p Part) Equal(o Part) bool

Equal returns a boolean indicating whether this part is equal to the given part.

type Provider

type Provider int

Provider represents a cloud provider.

const (
	// ProviderNone means not using a provider e.g. using the local filesystem.
	ProviderNone Provider = iota

	// ProviderAWS is the AWS cloud provider.
	ProviderAWS

	// ProviderGCP is the Google Cloud Platform cloud provider.
	ProviderGCP

	// ProviderAzure is the Microsoft Azure cloud provider.
	ProviderAzure
)

func (Provider) String

func (p Provider) String() string

String returns a human readable representation of the cloud provider.

func (Provider) ToScheme

func (p Provider) ToScheme() string

ToScheme converts Provider to a scheme (e.g. file://).

type TestBucket

type TestBucket map[string]*TestObject

TestBucket represents a bucket and is only used by the 'TestClient' to store objects in memory.

type TestBuckets

type TestBuckets map[string]TestBucket

TestBuckets represents a number of buckets, and is only used by the 'TestClient' to store state in memory.

type TestObject

type TestObject struct {
	ObjectAttrs
	Body []byte
}

TestObject represents an object and is only used by the 'TestObject'.

Jump to

Keyboard shortcuts

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