fileop

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2021 License: Apache-2.0, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArchiveAtomicOp

func ArchiveAtomicOp(file *os.File, activePath, archivePath string, deleteActiveFile, deleteInsteadOfArchiving bool) (isActiveFileDeeleted bool, err error)

ArchiveAtomicOp archive atomic op

func GetFileBufferFromFile added in v0.0.13

func GetFileBufferFromFile(file *os.File, fileBuf *wutils.Buffer) error

GetFileBufferFromFile get the file content

func TruncateAtomicOp

func TruncateAtomicOp(offset uint64, file *os.File) error

TruncateAtomicOp truncate atomic op

func WriteAtomicOp

func WriteAtomicOp(buffer []byte, offset uint64, fileSize uint64, file *os.File) error

WriteAtomicOp write atomic op

Types

type BucketFileOperationner

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

BucketFileOperationner will manage the concurrency to access files

func InitBucketFileOperationner

func InitBucketFileOperationner(c config.Config, logger *zap.Logger) (*BucketFileOperationner, error)

InitBucketFileOperationner init a BucketFileOperationner

func (*BucketFileOperationner) ApplyBatchOp

func (bfo *BucketFileOperationner) ApplyBatchOp(files []*FileBatchOp) ErrorFOPList

ApplyBatchOp execute the operations in one atomic operation

func (*BucketFileOperationner) Archive

func (bfo *BucketFileOperationner) Archive(cf *config.ContainerFile, shardIndex, walIndex, operationIndex int, deleteActiveFile bool) (deletedFile bool, err error)

Archive file

func (*BucketFileOperationner) Close

func (bfo *BucketFileOperationner) Close()

Close close all file and clear all data

func (*BucketFileOperationner) CurFileSize

func (bfo *BucketFileOperationner) CurFileSize(cf *config.ContainerFile) (int64, error)

CurFileSize get cur file size

func (*BucketFileOperationner) GetFileBuffer

func (bfo *BucketFileOperationner) GetFileBuffer(cf *config.ContainerFile, fileBuf *wutils.Buffer) error

GetFileBuffer get the file content

func (*BucketFileOperationner) Sync

Sync file

func (*BucketFileOperationner) Truncate

func (bfo *BucketFileOperationner) Truncate(cf *config.ContainerFile, offset int64) error

Truncate truncate file

func (*BucketFileOperationner) WriteAt

func (bfo *BucketFileOperationner) WriteAt(cf *config.ContainerFile, buf []byte, offset int64, fileSize int64) error

WriteAt write to a file

type ErrorFOP

type ErrorFOP struct {
	Err            error
	Fbo            *FileBatchOp
	OperationIndex int
}

ErrorFOP describe an error to a specific operation index

type ErrorFOPList

type ErrorFOPList []ErrorFOP

ErrorFOPList is a list of *Errors. The zero value for an ErrorFOPList is an empty ErrorFOPList ready to use.

func (*ErrorFOPList) Add

func (p *ErrorFOPList) Add(err ErrorFOP)

Add adds an Error with given position and error message to an ErrorFOPList.

func (ErrorFOPList) Err

func (p ErrorFOPList) Err() error

Err returns an error equivalent to this error list. If the list is empty, Err returns nil.

func (ErrorFOPList) Error

func (p ErrorFOPList) Error() string

An ErrorFOPList implements the error interface.

func (ErrorFOPList) GetErrorForFop

func (p ErrorFOPList) GetErrorForFop(fbo *FileBatchOp) *ErrorFOP

GetErrorForFop get the ErrorFOP corresponding to a FileBatchOp

func (ErrorFOPList) Len

func (p ErrorFOPList) Len() int

Len of the list

func (*ErrorFOPList) Reset

func (p *ErrorFOPList) Reset()

Reset resets an ErrorFOPList to no errors.

type FileBatchOp

type FileBatchOp struct {
	ContainerFile config.ContainerFile
	Ops           []Op
}

type Op

type Op struct {
	OpKind          OpKind
	Buffer          *wutils.Buffer
	Offset          uint64
	FileSize        int64
	OperationIndex  uint64
	ArchiveFileName string
	ActiveFileName  string
}

type OpKind

type OpKind uint8
const (
	WriteOp    OpKind = iota
	ArchiveOp  OpKind = iota
	TruncateOp OpKind = iota
)

Jump to

Keyboard shortcuts

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