iocontroller

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const FilePerm = 0644

FilePerm default permission of the newly created log file.

Variables

View Source
var ErrInvalidFsize = errors.New("fsize can`t be zero or negative")

ErrInvalidFsize invalid file size.

Functions

This section is empty.

Types

type FileIOController

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

FileIOController represents using standard file I/O.

func (*FileIOController) Close

func (f *FileIOController) Close() error

func (*FileIOController) Delete

func (f *FileIOController) Delete() error

func (*FileIOController) Read

func (f *FileIOController) Read(b []byte, offset int64) (int, error)

func (*FileIOController) Sync

func (f *FileIOController) Sync() error

func (*FileIOController) Write

func (f *FileIOController) Write(b []byte, offset int64) (int, error)

type IOController

type IOController interface {
	// Write a slice to log file at offset.
	// It returns the number of bytes written and any error encountered.
	Write(b []byte, offset int64) (int, error)

	// Read a slice from offset.
	// It returns the number of bytes read and any error encountered.
	Read(b []byte, offset int64) (int, error)

	// Sync commits the current contents of the file from memory to stable storage.
	Sync() error

	// Close closes the File.
	Close() error

	// Delete delete the file.
	Delete() error
}

func NewFileIOController

func NewFileIOController(fName string, fsize int64) (IOController, error)

NewFileIOController creates a new file io selector.

func NewMMapController

func NewMMapController(fName string, fsize int64) (IOController, error)

NewMMapController creates a new MMap controller

type MMapController

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

MMapController represents using memory map I/O.

func (*MMapController) Close

func (m *MMapController) Close() error

Close closes fd

func (*MMapController) Delete

func (m *MMapController) Delete() error

Delete deleted file on disk

func (*MMapController) Read

func (m *MMapController) Read(b []byte, offset int64) (int, error)

Read reads mapped region at offset into slice b

func (*MMapController) Sync

func (m *MMapController) Sync() error

Sync synchronize the mapped buffer to the file's contents on disk.

func (*MMapController) Write

func (m *MMapController) Write(b []byte, offset int64) (int, error)

Write writes slice b into mapped region(buf) at offset

Jump to

Keyboard shortcuts

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