storage

package
v0.0.0-...-dfdc05b Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

This package stores files in AWS S3 (and metadata in DynamoDB), allowing for incremental writes of multiple of BlockSize. For each file it stores a "metadata" record and a series of "block" records. Files and data expire after a predefined TTL.

This package stores files in BadgerDB, allowing for incremental writes of multiple of BlockSize. For each file it stores a "metadata" record and a series of "block" records. Files and data expire after a predefined TTL.

This package stores files in BadgerDB, allowing for incremental writes of multiple of BlockSize. For each file it stores a "metadata" record and a series of "block" records. Files and data expire after a predefined TTL.

Index

Constants

View Source
const (
	BlockSize          = 16 * 1024
	FileComplete int64 = -1
	InvalidPos   int64 = -2
)

Variables

View Source
var (
	ErrExists      = fmt.Errorf("File exists")
	ErrNotFound    = fmt.Errorf("File not found")
	ErrInvalidSize = fmt.Errorf("Invalid Size")
	ErrInvalidPos  = fmt.Errorf("Invalid Position")
	ErrInvalidHash = fmt.Errorf("Invalid Hash")
	ErrIncomplete  = fmt.Errorf("File incomplete")
)

Functions

func GetHash

func GetHash(r io.Reader) ([]byte, int64, error)

func Nint

func Nint(s *string) int64

func OpenAWS

func OpenAWS(dataFolder string, ttl time.Duration) (*awsStorage, error)

Open data folder and return instance of storage service

func OpenBadger

func OpenBadger(dataFolder string, readonly bool, ttl time.Duration) (*badgerStorage, error)

Open data folder and return instance of storage service

Types

type FileInfo

type FileInfo struct {
	Name        string
	ContentType string
	Hash        string
	Length      int64
	Next        int64
	Created     time.Time
	ExpiresAt   time.Time
}

User file info, returned by Stat

func (*FileInfo) String

func (f *FileInfo) String() string

type StorageDB

type StorageDB interface {
	CreateFile(key, filename, ctype string, size int64, hash []byte) error
	DeleteFile(key string) error
	Close() error
	WriteAt(key string, pos int64, data []byte) (int64, error)
	ReadAt(key string, buf []byte, pos int64) (int64, error)
	Stat(key string) (*FileInfo, error)

	GC() error
	Scan(start string) error
}

The interface to storage services

Jump to

Keyboard shortcuts

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