impl

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2020 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

This section is empty.

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, debugLog bool) (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 NewRamService

func NewRamService(cache interf.Cache, debugLog bool) 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, debugLog bool) (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, debugLog bool, 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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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