buckets

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	ID       string
	Name     string // 桶名称
	Provider string // 驱动名称

	EndpointDN string
	BucketDN   string
	Credential string

	Driver Driver
	Ext    map[string]string
}

Bucket 表示对某个具体存储桶的配置

type Connection

type Connection interface {
	io.Closer

	Check() error

	GetObject(name string) Object

	GetBucketName() string
}

Connection 表示与某个具体存储桶的连接

type Connector

type Connector interface {
	Open(b *Bucket) (Connection, error)
}

Connector 表示一个连接器

type Driver

type Driver interface {
	GetConnector() Connector

	// 从 properties 中加载 bucket 的参数
	GetBucket(tag, id string, p collection.Properties) (*Bucket, error)
}

Driver 表示为某种存储方案提供的的驱动

type DriverRegistration

type DriverRegistration struct {
	Name   string
	Driver Driver
}

DriverRegistration 用来表示某个驱动的注册信息

type DriverRegistry

type DriverRegistry interface {
	ListDrivers() []*DriverRegistration
}

DriverRegistry 用来枚举供应商提供的驱动 【inject:".buckets.Driver"】

type HTTPUploading added in v0.1.1

type HTTPUploading struct {
	UseHTTPS       bool
	Method         string
	URL            string
	ContentType    string
	ContentLength  int64
	ContentMD5     util.Hex
	MaxAge         int64 // in seconds
	RequestHeaders map[string]string
}

HTTPUploading ...

type Manager

type Manager interface {
	FindDriver(name string) (Driver, error)

	OpenBucket(b *Bucket) (Connection, error)

	GetBucket(tag, id string, p collection.Properties) (*Bucket, error)
}

Manager 用来统一管理各种驱动的管理器 【inject:"#buckets.Manager"】

type Object

type Object interface {
	Exists() (bool, error)
	GetDownloadURL() string
	GetMeta() (*ObjectMeta, error)
	GetName() string
	UpdateMeta(meta *ObjectMeta) error
	GetEntity() (ObjectEntity, error)
	PutEntity(entity ObjectEntity, meta *ObjectMeta) error
	PutFile(file fs.Path, meta *ObjectMeta) error

	// UploadByAPI 准备上传参数;
	// 输入:待准备的参数;
	// 输出:已经准备好的参数;
	UploadByAPI(up *HTTPUploading) (*HTTPUploading, error)
}

Object 表示对一个对象的引用

type ObjectEntity

type ObjectEntity interface {
	GetSize() int64
	Open() (io.ReadCloser, error)
}

ObjectEntity 表示对象的实体

func NewEntityForBytes

func NewEntityForBytes(b []byte) (ObjectEntity, error)

NewEntityForBytes ...

func NewEntityForFile

func NewEntityForFile(file fs.Path) (ObjectEntity, error)

NewEntityForFile ...

func NewEntityForFileName

func NewEntityForFileName(filename string) (ObjectEntity, error)

NewEntityForFileName ...

type ObjectMeta

type ObjectMeta struct {
	Size          int64
	Date          time.Time
	Hash          string
	HashAlgorithm string
	ContentType   string
	More          map[string]string
}

ObjectMeta 表示对象的元数据

Jump to

Keyboard shortcuts

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