impl

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2021 License: MIT Imports: 22 Imported by: 4

Documentation

Overview

Package impl provides default and base implementations for specialized storage service implementations like gdrive.

Index

Constants

View Source
const DebugHigh = 2

DebugHigh shows all debug messages.

View Source
const DebugLow = 1

DebugLow shows debug messages that happen very rarely during operation (to keep the log files small).

View Source
const DebugOff = 0

DebugOff deactivates all debug messages. Errors, warnings or information are still printed.

Variables

This section is empty.

Functions

func FileByAttr

func FileByAttr(files []interf.File, name string, size int64, md5 string) (interf.File, error)

FileByAttr returns the first file found with the requested attributes. If the parameter md5 is empty, this attribute is not considered in the search. If no file is found, the os.ErrNotExist error is returned. The data source is the specified list of files (attribute files).

func FileById

func FileById(files map[string]interf.File, id string) (interf.File, error)

FileById returns the file with the requested file id. If no file is found, the os.ErrNotExist error is returned. The data source is the specified list of files (attribute files).

func FileByName

func FileByName(files []interf.File, name string) (interf.File, error)

FileByName returns the latest (File.ModTime) file found with the requested name. If no file is found, the os.ErrNotExist error is returned. The data source is the specified list of files (attribute files).

func InitDemo

func InitDemo(s interf.Service) error

InitDemo creates the following test files:

  • over 1000 small test files Name: small-test-file-%d.dat Data: text == filename
  • 150 MB big test file (150*1024*1024 + 1 byte) Name: big-test-file-150.dat Data: random bytes MD5: 4DB84342E76FC08B993C528E2C2CDC6A
  • ...

func NewCache

func NewCache(cacheSizeMB int) interf.Cache

NewCache return the default implementation of interf.Cache. cacheSizeMB can't be less than 17 (min. 1024 * SectorSize =~ 17 MB).

func NewFile

func NewFile(id, name string, modTime, size int64, md5 string) interf.File

NewFile return the default implementation of interf.File. This encapsulates the given data.

func NewFiles

func NewFiles(byId map[string]interf.File) interf.Files

NewFiles return the default implementation of interf.Files. If the map is nil, a valid empty map is generated.

func NewMultiReaderAt

func NewMultiReaderAt(files []interf.File, service interf.ReaderService, cache interf.Cache, debugLvl uint8) (interf.ReaderAt, error)

NewMultiReader combine two or more ReaderAt and behave like a normal ReaderAT for a single file. All files except the last file must be the same size. There must be at least two or more files!

func NewRamReaderAt added in v1.1.3

func NewRamReaderAt(data []byte) interf.ReaderAt

NewRamReaderAt return a ReaderAt implementation that provides data from the ram ([]byte).

func NewRamService

func NewRamService(cache interf.Cache, debugLvl uint8) interf.Service

NewRamService return the RAM implementation of interf.Service. The data are only in RAM. This implementation is mainly for testing.

func NewReaderAt

func NewReaderAt(file interf.File, service interf.ReaderService, cache interf.Cache, debugLvl uint8) (interf.ReaderAt, error)

NewReaderAt creates a new interf.ReaderAt object for random read access to the file. No connections are made before the first call of ReadAt(). Is cache = nil, the cache is disabled.

func NewSubReaderAt added in v1.1.1

func NewSubReaderAt(file interf.File, service interf.ReaderService, cache interf.Cache, debugLvl uint8, off, n int64) (interf.ReaderAt, error)

NewSubReaderAt creates a new interf.ReaderAt object for random read access to the file. This implementation enables the ReaderAt methods to a part of a file. No connections are made before the first call of ReadAt(). Is cache = nil, the cache is disabled. The offset off is the part start point and n the part size.

func NewZeroReaderAt added in v1.1.2

func NewZeroReaderAt() interf.ReaderAt

NewZeroReaderAt is a dummy ReaderAt with no data.

Types

This section is empty.

Jump to

Keyboard shortcuts

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