objects

package
v7.25.2 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SkipDir = filepath.SkipDir

Functions

This section is empty.

Types

type BatchOpsExecutor

type BatchOpsExecutor interface {
	ExecuteBatchOps(context.Context, []Operation, *apis.Storage) error
}

批处理执行器

func NewConcurrentBatchOpsExecutor

func NewConcurrentBatchOpsExecutor(options *ConcurrentBatchOpsExecutorOptions) BatchOpsExecutor

创建并行批处理执行器

func NewSerialBatchOpsExecutor

func NewSerialBatchOpsExecutor(options *SerialBatchOpsExecutorOptions) BatchOpsExecutor

创建串型批处理执行器

type BatchOptions

type BatchOptions struct {
	// 批处理执行器,如果不填写,默认使用 ObjectsManager 的批处理执行器
	BatchOpsExecutor BatchOpsExecutor
}

批处理选项

type Bucket

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

存储空间

func (*Bucket) Directory

func (bucket *Bucket) Directory(prefix, pathSeparator string) *Directory

获取存储空间目录

func (*Bucket) List

func (bucket *Bucket) List(ctx context.Context, options *ListObjectsOptions) Lister

列举对象

func (*Bucket) Name

func (bucket *Bucket) Name() string

存储空间名称

func (*Bucket) Object

func (bucket *Bucket) Object(name string) *Object

获取存储空间对象

type ConcurrentBatchOpsExecutorOptions

type ConcurrentBatchOpsExecutorOptions struct {
	RetryMax          uint          // 最大重试次数,默认为 10
	InitBatchSize     uint          // 初始批次大小,默认为 250
	MaxBatchSize      uint          // 最大批次大小,默认为 250
	MinBatchSize      uint          // 最小批次大小,默认为 50
	DoublingFactor    uint          // 批次大小翻倍系数,默认为 2
	DoublingInterval  time.Duration // 翻倍时间间隔,默认为 1 分钟
	InitWorkers       uint          // 初始化并发数,默认为 20
	MaxWorkers        uint          // 最大并发数,默认为 20
	MinWorkers        uint          // 最小并发数,默认为 1
	AddWorkerInterval time.Duration // 增加并发数时间间隔,默认为 1 分钟
}

并行批处理执行器选项

type CopyObjectOperation

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

复制对象操作

func (*CopyObjectOperation) Call

func (operation *CopyObjectOperation) Call(ctx context.Context) error

func (*CopyObjectOperation) Force

func (operation *CopyObjectOperation) Force(force bool) *CopyObjectOperation

func (*CopyObjectOperation) OnError

func (operation *CopyObjectOperation) OnError(fn func(error)) *CopyObjectOperation

func (*CopyObjectOperation) OnResponse

func (operation *CopyObjectOperation) OnResponse(fn func()) *CopyObjectOperation

func (*CopyObjectOperation) String

func (operation *CopyObjectOperation) String() string

type DeleteObjectOperation

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

删除对象操作

func (*DeleteObjectOperation) Call

func (operation *DeleteObjectOperation) Call(ctx context.Context) error

func (*DeleteObjectOperation) OnError

func (operation *DeleteObjectOperation) OnError(fn func(error)) *DeleteObjectOperation

func (*DeleteObjectOperation) OnResponse

func (operation *DeleteObjectOperation) OnResponse(fn func()) *DeleteObjectOperation

func (*DeleteObjectOperation) String

func (operation *DeleteObjectOperation) String() string

type Directory

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

目录

func (*Directory) CopyTo

func (directory *Directory) CopyTo(ctx context.Context, toBucketName, toPrefix string) error

复制目录

func (*Directory) Delete

func (directory *Directory) Delete(ctx context.Context) error

删除目录

func (*Directory) ListEntries

func (directory *Directory) ListEntries(ctx context.Context, options *ListEntriesOptions, f func(*Entry) error) error

列举目录条目

func (*Directory) MoveTo

func (directory *Directory) MoveTo(ctx context.Context, toBucketName, toPrefix string) error

移动目录

type Entry

type Entry struct {
	// 目录名称,仅当条目为目录时才有效
	DirectoryName string

	// 对象元信息,仅当条目为对象时才有效
	Object *ObjectDetails
}

条目

type ListEntriesOptions

type ListEntriesOptions struct {
	NeedParts bool // 是否需要分片信息
	Recursive bool // 是否递归列举
}

列举条目选项

type ListObjectsOptions

type ListObjectsOptions struct {
	Limit     *uint64 // 最大列举数量
	Prefix    string  // 前缀
	Marker    string  // 标记
	NeedParts bool    // 是否需要分片信息
}

列举对象选项

type Lister

type Lister interface {
	io.Closer

	// 读取下一条记录
	Next(*ObjectDetails) bool

	// 获取错误信息
	Error() error

	// 获取位置标记
	Marker() string
}

对象列举接口

type ListerVersion

type ListerVersion int64

列举 API 版本

const (
	// 列举 V1
	ListerVersionV1 ListerVersion = iota
)

type MoveObjectOperation

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

移动对象操作

func (*MoveObjectOperation) Call

func (operation *MoveObjectOperation) Call(ctx context.Context) error

func (*MoveObjectOperation) Force

func (operation *MoveObjectOperation) Force(force bool) *MoveObjectOperation

func (*MoveObjectOperation) OnError

func (operation *MoveObjectOperation) OnError(fn func(error)) *MoveObjectOperation

func (*MoveObjectOperation) OnResponse

func (operation *MoveObjectOperation) OnResponse(fn func()) *MoveObjectOperation

func (*MoveObjectOperation) String

func (operation *MoveObjectOperation) String() string

type Object

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

对象

func (*Object) CopyTo

func (object *Object) CopyTo(toBucketName, toObjectName string) *CopyObjectOperation

复制对象

func (*Object) Delete

func (object *Object) Delete() *DeleteObjectOperation

删除对象

func (*Object) MoveTo

func (object *Object) MoveTo(toBucketName, toObjectName string) *MoveObjectOperation

移动对象

func (*Object) Restore

func (object *Object) Restore(freezeAfterDays int64) *RestoreObjectOperation

解冻对象

func (*Object) SetLifeCycle

func (object *Object) SetLifeCycle() *SetObjectLifeCycleOperation

设置对象生命周期

func (*Object) SetMetadata

func (object *Object) SetMetadata(mimeType string) *SetObjectMetadataOperation

设置对象元信息

func (*Object) SetStatus

func (object *Object) SetStatus(status Status) *SetObjectStatusOperation

设置对象状态

func (*Object) SetStorageClass

func (object *Object) SetStorageClass(storageClass StorageClass) *SetObjectStorageClassOperation

设置对象存储类型

func (*Object) Stat

func (object *Object) Stat() *StatObjectOperation

获取对象元信息

func (Object) String

func (entry Object) String() string

type ObjectDetails

type ObjectDetails struct {
	Name                    string         // 对象名称
	UploadedAt              time.Time      // 上传时间
	ETag                    string         // 哈希值
	Size                    int64          // 对象大小,单位为字节
	MimeType                string         // 对象 MIME 类型
	StorageClass            StorageClass   // 存储类型
	EndUser                 string         // 唯一属主标识
	Status                  Status         // 存储状态
	RestoreStatus           RestoreStatus  // 冻结状态,仅对归档存储或深度归档存储的对象生效
	TransitionToIA          *time.Time     // 文件生命周期中转为低频存储的日期
	TransitionToArchiveIR   *time.Time     // 文件生命周期中转为归档直读存储的日期
	TransitionToArchive     *time.Time     // 文件生命周期中转为归档存储的日期
	TransitionToDeepArchive *time.Time     // 文件生命周期中转为深度归档存储的日期
	ExpireAt                *time.Time     // 文件过期删除日期
	MD5                     [md5.Size]byte // 对象 MD5 值
	Metadata                map[string]string
	Parts                   []int64 // 分片的大小
}

对象详情

type ObjectsManager

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

对象管理器

func NewObjectsManager

func NewObjectsManager(options *ObjectsManagerOptions) *ObjectsManager

创建对象管理器

func (*ObjectsManager) Batch

func (objectsManager *ObjectsManager) Batch(ctx context.Context, operations []Operation, options *BatchOptions) error

执行批处理操作

func (*ObjectsManager) Bucket

func (objectsManager *ObjectsManager) Bucket(name string) *Bucket

获取存储空间

type ObjectsManagerOptions

type ObjectsManagerOptions struct {
	// HTTP 客户端选项
	httpclient.Options

	// 分片列举版本,如果不填写,默认为 V1
	ListerVersion ListerVersion

	// 批处理执行器,如果不填写,默认为串型批处理执行器
	BatchOpsExecutor BatchOpsExecutor
}

对象管理器选项

type Operation

type Operation interface {
	// 批量请求命令
	fmt.Stringer
	// contains filtered or unexported methods
}

操作接口,用于发送单次请求或批量请求

type RestoreObjectOperation

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

解冻对象操作

func (*RestoreObjectOperation) Call

func (operation *RestoreObjectOperation) Call(ctx context.Context) error

func (*RestoreObjectOperation) OnError

func (operation *RestoreObjectOperation) OnError(fn func(error)) *RestoreObjectOperation

func (*RestoreObjectOperation) OnResponse

func (operation *RestoreObjectOperation) OnResponse(fn func()) *RestoreObjectOperation

func (*RestoreObjectOperation) String

func (operation *RestoreObjectOperation) String() string

type RestoreStatus

type RestoreStatus int64

解冻状态

const (
	// 冻结中
	FrozenStatus RestoreStatus = iota

	// 解冻中
	RestoringStatus

	// 已解冻
	RestoredStatus
)

type SerialBatchOpsExecutorOptions

type SerialBatchOpsExecutorOptions struct {
	RetryMax  uint // 最大重试次数,默认为 10
	BatchSize uint // 批次大小,默认为 1000
}

串行批处理执行器选项

type SetObjectLifeCycleOperation

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

设置对象生命周期操作

func (*SetObjectLifeCycleOperation) Call

func (operation *SetObjectLifeCycleOperation) Call(ctx context.Context) error

func (*SetObjectLifeCycleOperation) DeleteAfterDays

func (operation *SetObjectLifeCycleOperation) DeleteAfterDays(afterDays int64) *SetObjectLifeCycleOperation

func (*SetObjectLifeCycleOperation) OnError

func (operation *SetObjectLifeCycleOperation) OnError(fn func(error)) *SetObjectLifeCycleOperation

func (*SetObjectLifeCycleOperation) OnResponse

func (operation *SetObjectLifeCycleOperation) OnResponse(fn func()) *SetObjectLifeCycleOperation

func (*SetObjectLifeCycleOperation) String

func (operation *SetObjectLifeCycleOperation) String() string

func (*SetObjectLifeCycleOperation) ToArchiveAfterDays

func (operation *SetObjectLifeCycleOperation) ToArchiveAfterDays(afterDays int64) *SetObjectLifeCycleOperation

func (*SetObjectLifeCycleOperation) ToArchiveIRAfterDays

func (operation *SetObjectLifeCycleOperation) ToArchiveIRAfterDays(afterDays int64) *SetObjectLifeCycleOperation

func (*SetObjectLifeCycleOperation) ToDeepArchiveAfterDays

func (operation *SetObjectLifeCycleOperation) ToDeepArchiveAfterDays(afterDays int64) *SetObjectLifeCycleOperation

func (*SetObjectLifeCycleOperation) ToIAAfterDays

func (operation *SetObjectLifeCycleOperation) ToIAAfterDays(afterDays int64) *SetObjectLifeCycleOperation

type SetObjectMetadataOperation

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

设置对象元信息操作

func (*SetObjectMetadataOperation) Call

func (operation *SetObjectMetadataOperation) Call(ctx context.Context) error

func (*SetObjectMetadataOperation) Conditions

func (operation *SetObjectMetadataOperation) Conditions(conds map[string]string) *SetObjectMetadataOperation

func (*SetObjectMetadataOperation) Metadata

func (operation *SetObjectMetadataOperation) Metadata(metadata map[string]string) *SetObjectMetadataOperation

func (*SetObjectMetadataOperation) OnError

func (operation *SetObjectMetadataOperation) OnError(fn func(error)) *SetObjectMetadataOperation

func (*SetObjectMetadataOperation) OnResponse

func (operation *SetObjectMetadataOperation) OnResponse(fn func()) *SetObjectMetadataOperation

func (*SetObjectMetadataOperation) String

func (operation *SetObjectMetadataOperation) String() string

type SetObjectStatusOperation

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

设置对象状态

func (*SetObjectStatusOperation) Call

func (operation *SetObjectStatusOperation) Call(ctx context.Context) error

func (*SetObjectStatusOperation) OnError

func (operation *SetObjectStatusOperation) OnError(fn func(error)) *SetObjectStatusOperation

func (*SetObjectStatusOperation) OnResponse

func (operation *SetObjectStatusOperation) OnResponse(fn func()) *SetObjectStatusOperation

func (*SetObjectStatusOperation) String

func (operation *SetObjectStatusOperation) String() string

type SetObjectStorageClassOperation

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

设置对象存储类型操作

func (*SetObjectStorageClassOperation) Call

func (operation *SetObjectStorageClassOperation) Call(ctx context.Context) error

func (*SetObjectStorageClassOperation) OnError

func (*SetObjectStorageClassOperation) OnResponse

func (operation *SetObjectStorageClassOperation) OnResponse(fn func()) *SetObjectStorageClassOperation

func (*SetObjectStorageClassOperation) String

func (operation *SetObjectStorageClassOperation) String() string

type StatObjectOperation

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

获取对象元信息操作

func (*StatObjectOperation) Call

func (operation *StatObjectOperation) Call(ctx context.Context) (*ObjectDetails, error)

func (*StatObjectOperation) NeedParts

func (operation *StatObjectOperation) NeedParts(needParts bool) *StatObjectOperation

func (*StatObjectOperation) OnError

func (operation *StatObjectOperation) OnError(fn func(error)) *StatObjectOperation

func (*StatObjectOperation) OnResponse

func (operation *StatObjectOperation) OnResponse(fn func(*ObjectDetails)) *StatObjectOperation

func (*StatObjectOperation) String

func (operation *StatObjectOperation) String() string

type Status

type Status int64

禁用状态

const (
	// 启用状态
	EnabledStatus Status = iota

	// 禁用状态
	DisabledStatus
)

type StorageClass

type StorageClass int64

存储类型

const (
	// 标准存储类型
	StandardStorageClass StorageClass = iota

	// 低频访问存储类型
	IAStorageClass

	// 归档存储类型
	ArchiveStorageClass

	// 深度归档存储类型
	DeepArchiveStorageClass

	// 归档直读存储类型
	ArchiveIRStorageClass
)

Jump to

Keyboard shortcuts

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