s3

package
v0.0.0-...-d88ec87 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrMsgNotFound issued if object does not exist
	ErrMsgNotFound = "404 Not Found"
	// AmzMetadataPrefix is constant for s3 specific header prefix
	AmzMetadataPrefix = "x-amz-meta-"
)

Variables

View Source
var (
	// ErrZeroContentLenthValue is the error returned when object in SRC has no content
	ErrZeroContentLenthValue = TextErr{errors.New("Content has zero length or hasn't size header")}
	// ErrContentLengthMaxValue is the error returned when object in SRC has no content
	ErrContentLengthMaxValue = TextErr{errors.New("Object size is to big")}
	// ErrEmptyContentType is the error returned when object hasn't Content-Type header
	ErrEmptyContentType = TextErr{errors.New("No Content-Type header")}
	// ErrDatabaseIntegrity is the error returned for all abnormal database cases
	ErrDatabaseIntegrity = TextErr{errors.New("Database integrity error")}
)

Functions

func CopyBucket

func CopyBucket(srcBucketName, dstBucketName string, srcS3Client *s3.S3, dstS3Client *s3.S3, shouldUseSrcBucketACL bool) (srcError, dstError error)

CopyBucket creates copy of source bucket on destination cluster

func DeleteObject

func DeleteObject(bucket *s3.Bucket, object string) error

DeleteObject deletes object from cluster

func GetHTTPStatusCodeFromError

func GetHTTPStatusCodeFromError(err error) int

GetHTTPStatusCodeFromError extracts http code from s3.Error value

func GetS3Client

func GetS3Client(s3Auth *MigrationAuth) *s3.S3

GetS3Client returns s3 client for given MigrationAuth

Types

type CompletePart

type CompletePart struct {
	PartNumber int
	ETag       string
}

type MigrationAuth

type MigrationAuth struct {
	Endpoint  string
	AccessKey string
	SecretKey string
}

MigrationAuth keeps auth data

type MigrationTaskData

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

MigrationTaskData validates and extracts object location data

func NewMigrationTaskData

func NewMigrationTaskData(action string,
	aclMode model.ACLMode,
	hostFrom, hostTo string,
	srcBucket, srcKey, dstBucket, dstKey string) MigrationTaskData

NewMigrationTaskData constructs an instance of MigrationTaskData

type MigrationTaskResult

type MigrationTaskResult struct {
	Tid                uint64
	Pid                uint64
	ErrorType          model.ErrorType
	Error              error
	NowToCreatedAtDiff int64
	Retryable          bool
	Success            bool
	IsPermanent        bool
}

MigrationTaskResult keeps track on migration task

func NewMigrationTaskResult

func NewMigrationTaskResult(task model.MigrationTaskItem) MigrationTaskResult

NewMigrationTaskResult creates MigrationTaskResult

func (*MigrationTaskResult) ApplyDefaultErrorStrategy

func (mtr *MigrationTaskResult) ApplyDefaultErrorStrategy(errType model.ErrorType, err error)

ApplyDefaultErrorStrategy prepares states for MigrationTaskResult and calls MarkRetry for error

func (*MigrationTaskResult) MarkRetry

func (mtr *MigrationTaskResult) MarkRetry(errType model.ErrorType, err error)

MarkRetry checks if error should terminate task execution

type MultipartUploader

type MultipartUploader struct {
	Bucket, Key, AccessKey, SecretKey, HostPort string
	PartSize                                    int64
	ObjectBody                                  io.Reader
	UploadId                                    string
	// contains filtered or unexported fields
}

func (*MultipartUploader) Complete

func (uploader *MultipartUploader) Complete() error

func (*MultipartUploader) Init

func (uploader *MultipartUploader) Init(contType string, perm goamzS3.ACL, options goamzS3.Options) error

func (*MultipartUploader) ListParts

func (uploader *MultipartUploader) ListParts() error

func (*MultipartUploader) URL

func (uploader *MultipartUploader) URL() (*url.URL, error)

func (*MultipartUploader) UnmarshalResp

func (uploader *MultipartUploader) UnmarshalResp(resp *http.Response, value interface{}) error

func (*MultipartUploader) UploadPart

func (uploader *MultipartUploader) UploadPart(n int, r io.ReadSeeker) (CompletePart, error)

func (*MultipartUploader) UploadParts

func (uploader *MultipartUploader) UploadParts(size int64) error

type Part

type Part struct {
	N    int `xml:"PartNumber"`
	ETag string
	Size int64
}

type TaskMigrator

type TaskMigrator struct {
	Task                     MigrationTaskData
	SrcS3Client, DstS3Client *s3.S3
	Multipart                bool
	// contains filtered or unexported fields
}

TaskMigrator encapsulates all necessary routines to execute task

func (*TaskMigrator) Run

func (migrator *TaskMigrator) Run() (srcError, dstError error)

Run performs task migration actions

type TextErr

type TextErr struct {
	Err error
}

TextErr is an error that also implements the TextMarshaller interface for serializing out to various plain text encodings. Packages creating their own custom errors should use TextErr if they're intending to use serializing formats like json, msgpack etc.

func (TextErr) Error

func (t TextErr) Error() string

Error implements the error interface.

func (TextErr) MarshalText

func (t TextErr) MarshalText() ([]byte, error)

MarshalText implements the TextMarshaller

Jump to

Keyboard shortcuts

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