objectstorage

package
v19.10.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2019 License: Apache-2.0 Imports: 16 Imported by: 24

Documentation

Index

Constants

View Source
const (
	// RootPath defines the path corresponding of the root of a Bucket
	RootPath = ""
	// NoPrefix corresponds to ... no prefix...
	NoPrefix = ""
)

Variables

This section is empty.

Functions

func BuildMetadataBucketName

func BuildMetadataBucketName(driver, region, domain, project string) (name string, err error)

BuildMetadataBucketName builds the name of the bucket/container that will store metadata

func BuildStorageBucketName

func BuildStorageBucketName(driver, region, domain, project string) (name string, err error)

BuildStorageBucketName builds the name of the bucket/container that will store metadata

Types

type Bucket

type Bucket interface {
	// List list object names in a Bucket
	List(string, string) ([]string, error)
	// BrowseObjects browses inside the Bucket and execute a callback on each Object found
	Browse(string, string, func(Object) error) error

	// CreateObject creates a new object in the bucket
	CreateObject(string) (Object, error)
	// GetObject returns Object instance of an object in the Bucket
	GetObject(string) (Object, error)
	// DeleteObject delete an object from a container
	DeleteObject(string) error
	// ReadObject reads the content of an object
	ReadObject(string, io.Writer, int64, int64) (Object, error)
	// WriteObject writes into an object
	WriteObject(string, io.Reader, int64, ObjectMetadata) (Object, error)
	// WriteMultiPartObject writes a lot of data into an object, cut in pieces
	WriteMultiPartObject(string, io.Reader, int64, int, ObjectMetadata) (Object, error)

	// GetName returns the name of the bucket
	GetName() string
	// GetCount returns the number of objects in the Bucket
	GetCount(string, string) (int64, error)
	// GetSize returns the total size of all objects in the bucket
	GetSize(string, string) (int64, string, error)
}

Bucket interface

type Config

type Config struct {
	Type             string
	EnvAuth          bool
	AuthVersion      int
	AuthURL          string
	EndpointType     string
	Endpoint         string
	TenantDomain     string
	Tenant           string
	Domain           string
	User             string
	Key              string
	SecretKey        string
	Region           string
	AvailabilityZone string
	ProjectID        string
	Credentials      string
}

Config ...

type Location

type Location interface {
	// ReadTenant(projectName string, provider string) (Config, error)
	GetType() string

	// ListBuckets returns all bucket prefixed by a string given as a parameter
	ListBuckets(string) ([]string, error)
	// FindBucket returns true of bucket exists in location
	FindBucket(string) (bool, error)
	// GetBucket returns info of the Bucket
	GetBucket(string) (Bucket, error)
	// Create a bucket
	CreateBucket(string) (Bucket, error)
	// DeleteBucket removes a bucket (need to be cleared before)
	DeleteBucket(string) error
	// ClearBucket empties a Bucket
	ClearBucket(string, string, string) error

	// ListObjects lists the objects in a Bucket
	ListObjects(string, string, string) ([]string, error)
	// GetObject ...
	GetObject(string, string) (Object, error)
	// ReadObject ...
	ReadObject(string, string, io.Writer, int64, int64) error
	// WriteMultiChunkObject ...
	WriteMultiPartObject(string, string, io.Reader, int64, int, ObjectMetadata) (Object, error)
	// WriteObject ...
	WriteObject(string, string, io.Reader, int64, ObjectMetadata) (Object, error)
	// // CopyObject copies an object
	// CopyObject(string, string, string) error
	// DeleteObject delete an object from a container
	DeleteObject(string, string) error
}

Location ...

func NewLocation

func NewLocation(conf Config) (Location, error)

NewLocation creates an Object Storage Location based on config

type Object

type Object interface {
	Stored() bool

	Read(io.Writer, int64, int64) error
	Write(io.Reader, int64) error
	WriteMultiPart(io.Reader, int64, int) error
	Reload() error
	Delete() error
	AddMetadata(ObjectMetadata)
	ForceAddMetadata(ObjectMetadata)
	ReplaceMetadata(ObjectMetadata)

	GetID() string
	GetName() string
	GetLastUpdate() (time.Time, error)
	GetSize() int64
	GetETag() string
	GetMetadata() ObjectMetadata
}

Object interface

type ObjectMetadata

type ObjectMetadata map[string]interface{}

ObjectMetadata ...

func (ObjectMetadata) Clone

func (om ObjectMetadata) Clone() ObjectMetadata

Clone creates a copy of ObjectMetadata

Jump to

Keyboard shortcuts

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