sources

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

README

Sources

Memory

MemoryStorage can be setup using NewMemoryStorage(size). A RWMutex is used to ensure safety. If you wish to support concurrent writes, one way would be to use a ShardedStorage module to split the memory into several blocks which can then be written to concurrently.

File

FileStorage can be setup using NewFileStorage(f, size) for an existing file, and NewFileStorageCreate(f, size) if you wish to create a new file.

FileSparse

FileStorageSparse can be setup using NewFileStorageSparseCreate(f, size, blockSize) for creating a new file. Only blocks which have been written to are stored in the file. Only supports reads for blocks that have already been written. Partial block reads are supported. Partial block writes are discarded.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDisabled = errors.New("disabled")
)

Functions

This section is empty.

Types

type FileStorage

type FileStorage struct {
	storage.ProviderWithEvents
	// contains filtered or unexported fields
}

*

  • Simple fixed size file storage provider *

func NewFileStorage

func NewFileStorage(f string, size int64) (*FileStorage, error)

func NewFileStorageCreate

func NewFileStorageCreate(f string, size int64) (*FileStorage, error)

func (*FileStorage) CancelWrites added in v0.0.5

func (i *FileStorage) CancelWrites(_ int64, _ int64)

func (*FileStorage) Close

func (i *FileStorage) Close() error

func (*FileStorage) Flush

func (i *FileStorage) Flush() error

func (*FileStorage) ReadAt

func (i *FileStorage) ReadAt(buffer []byte, offset int64) (int, error)

func (*FileStorage) Size

func (i *FileStorage) Size() uint64

func (*FileStorage) WriteAt

func (i *FileStorage) WriteAt(buffer []byte, offset int64) (int, error)

type FileStorageSparse added in v0.0.2

type FileStorageSparse struct {
	storage.ProviderWithEvents
	// contains filtered or unexported fields
}

*

  • Simple sparse file storage provider *
  • - Reads return error if no data has been written for a block yet.
  • - Partial block reads supported as long as the blocks exist.
  • - Partial block writes supported as long as the blocks exist (Have already been written to completely). *

func NewFileStorageSparse added in v0.0.3

func NewFileStorageSparse(f string, size uint64, blockSize int) (*FileStorageSparse, error)

func NewFileStorageSparseCreate added in v0.0.2

func NewFileStorageSparseCreate(f string, size uint64, blockSize int) (*FileStorageSparse, error)

func (*FileStorageSparse) CancelWrites added in v0.0.5

func (i *FileStorageSparse) CancelWrites(_ int64, _ int64)

func (*FileStorageSparse) Close added in v0.0.2

func (i *FileStorageSparse) Close() error

func (*FileStorageSparse) Flush added in v0.0.2

func (i *FileStorageSparse) Flush() error

func (*FileStorageSparse) ReadAt added in v0.0.2

func (i *FileStorageSparse) ReadAt(buffer []byte, offset int64) (int, error)

func (*FileStorageSparse) Size added in v0.0.2

func (i *FileStorageSparse) Size() uint64

func (*FileStorageSparse) WriteAt added in v0.0.2

func (i *FileStorageSparse) WriteAt(buffer []byte, offset int64) (int, error)

type MemoryStorage

type MemoryStorage struct {
	storage.ProviderWithEvents
	// contains filtered or unexported fields
}

*

  • Simple fixed size memory based storage provider * *

func NewMemoryStorage

func NewMemoryStorage(size int) *MemoryStorage

func (*MemoryStorage) CancelWrites added in v0.0.5

func (i *MemoryStorage) CancelWrites(_ int64, _ int64)

func (*MemoryStorage) Close added in v0.0.2

func (i *MemoryStorage) Close() error

func (*MemoryStorage) Flush

func (i *MemoryStorage) Flush() error

func (*MemoryStorage) ReadAt

func (i *MemoryStorage) ReadAt(buffer []byte, offset int64) (int, error)

func (*MemoryStorage) Size

func (i *MemoryStorage) Size() uint64

func (*MemoryStorage) WriteAt

func (i *MemoryStorage) WriteAt(buffer []byte, offset int64) (int, error)

type S3Metrics added in v0.0.10

type S3Metrics struct {
	BlocksWCount     uint64
	BlocksWBytes     uint64
	BlocksWDataBytes uint64
	BlocksWTime      time.Duration
	BlocksWPreRCount uint64
	BlocksWPreRBytes uint64
	BlocksWPreRTime  time.Duration
	BlocksRCount     uint64
	BlocksRBytes     uint64
	BlocksRDataBytes uint64
	BlocksRTime      time.Duration
	ActiveReads      uint64
	ActiveWrites     uint64
}

func (*S3Metrics) String added in v0.0.10

func (i *S3Metrics) String() string

type S3Storage added in v0.0.2

type S3Storage struct {
	storage.ProviderWithEvents
	// contains filtered or unexported fields
}

func NewS3Storage added in v0.0.2

func NewS3Storage(secure bool, endpoint string,
	access string,
	secretAccess string,
	bucket string,
	prefix string,
	size uint64,
	blockSize int) (*S3Storage, error)

func NewS3StorageCreate added in v0.0.2

func NewS3StorageCreate(secure bool, endpoint string,
	access string,
	secretAccess string,
	bucket string,
	prefix string,
	size uint64,
	blockSize int) (*S3Storage, error)

func NewS3StorageDummy added in v0.0.10

func NewS3StorageDummy(size uint64,
	blockSize int) (*S3Storage, error)

func (*S3Storage) CancelWrites added in v0.0.5

func (i *S3Storage) CancelWrites(offset int64, length int64)

func (*S3Storage) Close added in v0.0.2

func (i *S3Storage) Close() error

func (*S3Storage) Flush added in v0.0.2

func (i *S3Storage) Flush() error

func (*S3Storage) Metrics added in v0.0.10

func (i *S3Storage) Metrics() *S3Metrics

func (*S3Storage) ReadAt added in v0.0.2

func (i *S3Storage) ReadAt(buffer []byte, offset int64) (int, error)

func (*S3Storage) SetReadWriteEnabled added in v0.1.5

func (i *S3Storage) SetReadWriteEnabled(disabledReads bool, disabledWrites bool)

func (*S3Storage) Size added in v0.0.2

func (i *S3Storage) Size() uint64

func (*S3Storage) WriteAt added in v0.0.2

func (i *S3Storage) WriteAt(buffer []byte, offset int64) (int, error)

Jump to

Keyboard shortcuts

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