block

package
v0.0.1-beta Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: Apache-2.0, MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockstoreTypeS3        = "s3"
	BlockstoreTypeGS        = "gs"
	BlockstoreTypeAzure     = "azure"
	BlockstoreTypeLocal     = "local"
	BlockstoreTypeMem       = "mem"
	BlockstoreTypeTransient = "transient"
)
View Source
const (
	StorageTypeMem = iota
	StorageTypeLocal
	StorageTypeS3
	StorageTypeGS
	StorageTypeAzure
)
View Source
const (
	Separator = "/"

	EntryTypeTree   = "tree"
	EntryTypeObject = "object"
)
View Source
const DefaultPreSignExpiryDuration = 15 * time.Minute

DefaultPreSignExpiryDuration is the amount of time pre-signed requests are valid for.

Variables

View Source
var (
	ErrDataNotFound          = errors.New("not found")
	ErrOperationNotSupported = errors.New("operation not supported")
	ErrAsyncCopyFailed       = errors.New("async copy failed")
	ErrBadIndex              = errors.New("bad index")
	ErrForbidden             = errors.New("forbidden")
	ErrInvalidAddress        = errors.New("invalid address")
	ErrInvalidNamespace      = errors.New("invalid namespace")
)
View Source
var RootPath = NewPath("", EntryTypeTree)

Functions

func DefaultExample

func DefaultExample(scheme string) string

func DefaultValidationRegex

func DefaultValidationRegex(scheme string) string

func JoinPathParts

func JoinPathParts(parts []string) string

func ValidateStorageType

func ValidateStorageType(uri *url.URL, expectedStorage StorageType) error

Types

type Adapter

type Adapter interface {
	Put(ctx context.Context, obj ObjectPointer, sizeBytes int64, reader io.Reader, opts PutOpts) error
	Get(ctx context.Context, obj ObjectPointer, expectedSize int64) (io.ReadCloser, error)
	GetWalker(uri *url.URL) (Walker, error)

	// GetPreSignedURL returns a pre-signed URL for accessing obj with mode, and the
	// expiry time for this URL.  The expiry time IsZero() if reporting
	// expiry is not supported.  The expiry time will be sooner than
	// Config.*.PreSignedExpiry if an auth token is about to expire.
	GetPreSignedURL(ctx context.Context, obj ObjectPointer, mode PreSignMode) (string, time.Time, error)
	Exists(ctx context.Context, obj ObjectPointer) (bool, error)
	GetRange(ctx context.Context, obj ObjectPointer, startPosition int64, endPosition int64) (io.ReadCloser, error)
	GetProperties(ctx context.Context, obj ObjectPointer) (Properties, error)
	Remove(ctx context.Context, obj ObjectPointer) error
	RemoveNameSpace(ctx context.Context, storageNamespace string) error
	Copy(ctx context.Context, sourceObj, destinationObj ObjectPointer) error
	CreateMultiPartUpload(ctx context.Context, obj ObjectPointer, r *http.Request, opts CreateMultiPartUploadOpts) (*CreateMultiPartUploadResponse, error)
	UploadPart(ctx context.Context, obj ObjectPointer, sizeBytes int64, reader io.Reader, uploadID string, partNumber int) (*UploadPartResponse, error)
	UploadCopyPart(ctx context.Context, sourceObj, destinationObj ObjectPointer, uploadID string, partNumber int) (*UploadPartResponse, error)
	UploadCopyPartRange(ctx context.Context, sourceObj, destinationObj ObjectPointer, uploadID string, partNumber int, startPosition, endPosition int64) (*UploadPartResponse, error)
	AbortMultiPartUpload(ctx context.Context, obj ObjectPointer, uploadID string) error
	CompleteMultiPartUpload(ctx context.Context, obj ObjectPointer, uploadID string, multipartList *MultipartUploadCompletion) (*CompleteMultiPartUploadResponse, error)
	BlockstoreType() string
	GetStorageNamespaceInfo() StorageNamespaceInfo
	ResolveNamespace(storageNamespace, key string, identifierType IdentifierType) (QualifiedKey, error)
	RuntimeStats() map[string]string
}

type CommonQualifiedKey

type CommonQualifiedKey struct {
	StorageType      StorageType
	StorageNamespace string
	Key              string
}

func DefaultResolveNamespace

func DefaultResolveNamespace(defaultNamespace, key string, identifierType IdentifierType) (CommonQualifiedKey, error)

func (CommonQualifiedKey) Format

func (qk CommonQualifiedKey) Format() string

func (CommonQualifiedKey) GetKey

func (qk CommonQualifiedKey) GetKey() string

func (CommonQualifiedKey) GetStorageNamespace

func (qk CommonQualifiedKey) GetStorageNamespace() string

func (CommonQualifiedKey) GetStorageType

func (qk CommonQualifiedKey) GetStorageType() StorageType

type CompleteMultiPartUploadResponse

type CompleteMultiPartUploadResponse struct {
	ETag             string
	ContentLength    int64
	ServerSideHeader http.Header
}

CompleteMultiPartUploadResponse complete multipart etag, content length and additional headers (implementation specific) currently it targets s3. The ETag is a hex string value of the content checksum

type CreateMultiPartUploadOpts

type CreateMultiPartUploadOpts struct {
	StorageClass *string // S3 storage class
}

CreateMultiPartUploadOpts contains optional arguments for CreateMultiPartUpload. These should be analogous to options on some underlying storage layer. Missing arguments are mapped to the default if a storage layer implements the option.

If the same CreateMultiPartUpload command is implemented multiple times with the same contents but different option values, the first supplied option value is retained.

type CreateMultiPartUploadResponse

type CreateMultiPartUploadResponse struct {
	UploadID         string
	ServerSideHeader http.Header
}

CreateMultiPartUploadResponse multipart upload ID and additional headers (implementation specific) currently it targets s3 capabilities to enable encryption properties

type IdentifierType

type IdentifierType int32

IdentifierType is the type the ObjectPointer Identifier

const (
	// IdentifierTypeRelative indicates that the address is relative to the storage namespace.
	// For example: "/foo/bar"
	IdentifierTypeRelative IdentifierType = 1

	// IdentifierTypeFull indicates that the address is the full address of the object in the object store.
	// For example: "s3://bucket/foo/bar"
	IdentifierTypeFull IdentifierType = 2
)

type Mark

type Mark struct {
	ContinuationToken string
	LastKey           string
	HasMore           bool
}

type MultipartPart

type MultipartPart struct {
	ETag       string
	PartNumber int
}

MultipartPart single multipart information

type MultipartUploadCompletion

type MultipartUploadCompletion struct {
	Part []MultipartPart
}

MultipartUploadCompletion parts described as part of complete multipart upload. Each part holds the part number and ETag received while calling part upload. NOTE that S3 implementation and our S3 gateway accept and returns ETag value surrounded with double-quotes ("), while the adapter implementations supply the raw value of the etag (without double quotes) and let the gateway manage the s3 protocol specifications.

type ObjectPointer

type ObjectPointer struct {
	StorageNamespace string
	Identifier       string

	// Indicates whether the Identifier is relative to the StorageNamespace,
	// full address to an object, or unknown.
	IdentifierType IdentifierType
}

ObjectPointer is a unique identifier of an object in the object store: the store is a 1:1 mapping between pointers and objects.

type ObjectStoreEntry

type ObjectStoreEntry struct {
	// FullKey represents the fully qualified path in the object store namespace for the given entry
	FullKey string `json:"full_key,omitempty"`
	// RelativeKey represents a path relative to prefix (or directory). If none specified, will be identical to FullKey
	RelativeKey string `json:"relative_key,omitempty"`
	// Address is a full URI for the entry, including the storage namespace (i.e. s3://bucket/path/to/key)
	Address string `json:"address,omitempty"`
	// ETag represents a hash of the entry's content. Generally as hex encoded MD5,
	// but depends on the underlying object store
	ETag string `json:"etag,omitempty"`
	// Mtime is the last-modified datetime of the entry
	Mtime time.Time `json:"mtime,omitempty"`
	// Size in bytes
	Size int64 `json:"size"`
}

func (ObjectStoreEntry) String

func (e ObjectStoreEntry) String() string

type Path

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

func NewPath

func NewPath(str, entryType string) *Path

func (*Path) BaseName

func (p *Path) BaseName() string

func (*Path) Equals

func (p *Path) Equals(other *Path) bool

func (*Path) IsRoot

func (p *Path) IsRoot() bool

func (*Path) ParentPath

func (p *Path) ParentPath() string

func (*Path) Split

func (p *Path) Split() []string

func (*Path) String

func (p *Path) String() string

type PreSignMode

type PreSignMode int32

PreSignMode is the mode to use when generating a pre-signed URL (read/write)

const (
	PreSignModeRead PreSignMode = iota
	PreSignModeWrite
)

type Properties

type Properties struct {
	StorageClass *string
}

Properties of an object stored on the underlying block store. Refer to the actual underlying Adapter for which properties are actually reported.

type PutOpts

type PutOpts struct {
}

PutOpts contains optional arguments for Put. These should be analogous to options on some underlying storage layer. Missing arguments are mapped to the default if a storage layer implements the option.

If the same Put command is implemented multiple times with the same contents but different option values, the first supplied option value is retained.

type QualifiedKey

type QualifiedKey interface {
	Format() string
	GetStorageType() StorageType
	GetStorageNamespace() string
	GetKey() string
}

type StorageNamespaceInfo

type StorageNamespaceInfo struct {
	ValidityRegex          string // regex pattern that could be used to validate the namespace
	Example                string // example of a valid namespace
	DefaultNamespacePrefix string // when a repo is created from the UI, suggest a default storage namespace under this prefix
	PreSignSupport         bool
	PreSignSupportUI       bool
	ImportSupport          bool
	ImportValidityRegex    string
}

func DefaultStorageNamespaceInfo

func DefaultStorageNamespaceInfo(scheme string) StorageNamespaceInfo

type StorageType

type StorageType int

func GetStorageType

func GetStorageType(namespaceURL *url.URL) (StorageType, error)

func (StorageType) BlockstoreType

func (s StorageType) BlockstoreType() string

func (StorageType) Scheme

func (s StorageType) Scheme() string

type UploadPartResponse

type UploadPartResponse struct {
	ETag             string
	ServerSideHeader http.Header
}

UploadPartResponse upload part ETag and additional headers (implementation specific) currently it targets s3 capabilities to enable encryption properties The ETag is a hex string value of the content checksum

type WalkOptions

type WalkOptions struct {
	// After - all walked items must be greater than After
	After string

	// ContinuationToken is passed to the client for efficient listing. Value is Opaque to the caller.
	ContinuationToken string
}

type WalkOpts

type WalkOpts struct {
	StorageNamespace string
	Prefix           string
}

WalkOpts is a unique identifier of a prefix in the object store.

type Walker

type Walker interface {
	Walk(ctx context.Context, storageURI *url.URL, op WalkOptions, walkFn func(e ObjectStoreEntry) error) error
	Marker() Mark
	GetSkippedEntries() []ObjectStoreEntry
}

type WalkerOptions

type WalkerOptions struct {
	S3EndpointURL  string
	StorageURI     string
	SkipOutOfOrder bool
}

type WalkerWrapper

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

func NewWrapper

func NewWrapper(walker Walker, uri *url.URL) *WalkerWrapper

func (*WalkerWrapper) GetSkippedEntries

func (ww *WalkerWrapper) GetSkippedEntries() []ObjectStoreEntry

func (*WalkerWrapper) Marker

func (ww *WalkerWrapper) Marker() Mark

func (*WalkerWrapper) Walk

func (ww *WalkerWrapper) Walk(ctx context.Context, opts WalkOptions, walkFn func(e ObjectStoreEntry) error) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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