extremofile

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2019 License: CC0-1.0 Imports: 9 Imported by: 0

README

What

Extremofile is single binary value persistent storage that makes best effort to read your data back unchanged. GoDoc

Use case

Answer yes to all questions:

  • Need to persist small amount of data? It costs 2 full data writes + fsync on each store operation.
  • Expect power loss or storage media degradation? If you have reliable power supply and storage, that's awesome.
  • Network backup is not available? If you have robust remote database available when you need it, that's great.

Failure modes tolerated:

  • power loss
  • random data corrupted in one replica

Failure modes detected:

  • almost any data corruption, limited to checksum mismatch

Failures not handled by design: human error, files deleted.

API guarantees

  • You only get valid value bytes.
  • You may get value/writer together with non-critical error.
  • Internal storage format may change with major version.
  • Library will read one previous storage format.
  • Thread-safe.
  • Not safe to use by multiple processes, data may be corrupted.

FAQ

  • Why not SQLite or goleveldb or X?

    I could not find a ready solution that actually survives storage media degradation, rather than just reporting error. If you need similar durability with complex data structure, wrap your database of choice with automatic backup.

Flair

Build status Coverage Go Report Card

Documentation

Index

Constants

View Source
const DefaultDirPerm os.FileMode = 0700
View Source
const DefaultFilePerm os.FileMode = 0600
View Source
const DefaultFilePrefix = "extremofile."

Variables

This section is empty.

Functions

func IsCorrupt

func IsCorrupt(e error) bool

data is corrupted, restore is not possible

func IsCritical

func IsCritical(e error) bool

storage is not available, most commonly: disk is full or fs permission error

func New

func New(config Config) *efile

Does not perform IO.

func Open

func Open(dir string) ([]byte, io.Writer, error)

Open is simpler API, checks write access. Bytes and Writer may be not nil together with error to indicate non fatal issues.

Types

type Config

type Config struct {
	Dir        string
	FilePrefix string
	DirPerm    os.FileMode
	FilePerm   os.FileMode
	MustExist  bool
	ReadOnly   bool
}

Jump to

Keyboard shortcuts

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