storage

package
v0.1.2-fix-5 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: GPL-3.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultObjectStorage

type DefaultObjectStorage struct{}

func (DefaultObjectStorage) CreateBucket

func (s DefaultObjectStorage) CreateBucket(ctx context.Context) error

func (DefaultObjectStorage) ListAllObjects

func (s DefaultObjectStorage) ListAllObjects(ctx context.Context, prefix, marker string) (<-chan Object, error)

func (DefaultObjectStorage) ListObjects

func (s DefaultObjectStorage) ListObjects(ctx context.Context, prefix, marker, delimiter string, limit int64) ([]Object, error)

type Object

type Object interface {
	Key() string
	Size() int64
	ModTime() time.Time
	IsSymlink() bool
}

Object

type ObjectStorage

type ObjectStorage interface {
	// String the description of an object storage
	String() string
	// CreateBucket create the bucket if not existed
	CreateBucket(ctx context.Context) error
	// GetObject gets data for the given object specified by key
	GetObject(ctx context.Context, key string, offset, limit int64) (io.ReadCloser, error)
	// PutObject puts data read from a reader to an object specified by key
	PutObject(ctx context.Context, key string, reader io.Reader) error
	// DeleteObject deletes an object
	DeleteObject(ctx context.Context, key string) error

	// HeadBucket determines if a bucket exists and have permission to access it
	HeadBucket(ctx context.Context) error
	// HeadObject returns some information about the object or an error if not found
	HeadObject(ctx context.Context, key string) (Object, error)
	// ListObjects lists returns a list of objects
	ListObjects(ctx context.Context, prefix, marker, delimiter string, limit int64) ([]Object, error)
	// ListAllObjects returns all the objects as a channel
	ListAllObjects(ctx context.Context, prefix, marker string) (<-chan Object, error)
}

ObjectStorage is a common interface that must be implemented if some users want to use an object storage (such as S3, Azure Blob, Minio, OSS, COS, etc)

func NewObjectStorage

func NewObjectStorage(cfg ObjectStorageConfig) (ObjectStorage, error)

func NewSharded

func NewSharded(cfg PieceStoreConfig) (ObjectStorage, error)

type ObjectStorageConfig

type ObjectStorageConfig struct {
	Storage               string // backend storage type (e.g. s3, file, memory)
	BucketURL             string // the bucket URL of object storage to store data
	MaxRetries            int    // the number of max retries that will be performed
	MinRetryDelay         int64  // the minimum retry delay after which retry will be performed
	TLSInsecureSkipVerify bool   // whether skip the certificate verification of HTTPS requests
	IAMType               string // IAMType is identity and access management type which contains two types: AKSKIAMType/SAIAMType
}

ObjectStorageConfig object storage config

type PieceStoreConfig

type PieceStoreConfig struct {
	Shards int                 // store the blocks into N buckets by hash of key
	Store  ObjectStorageConfig // config of object storage
}

PieceStoreConfig contains some parameters which are used to run PieceStore

type SessionCache

type SessionCache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

SessionCache holds session.Session according to ObjectStorageConfig and it synchronizes access/modification

type StorageFn

type StorageFn func(cfg ObjectStorageConfig) (ObjectStorage, error)

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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