bprovider

package
v0.0.0-...-a2e7767 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2020 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExists = errors.New("file exists")
View Source
var ErrInvalidArgument = errors.New("invalid argument")
View Source
var ErrNoSpace = errors.New("no more space")

Functions

This section is empty.

Types

type Segment

type Segment interface {
	//Returns the address of the first free word in the segment when it was locked
	BaseAddress() uint64

	//Unlocks the segment for the StorageProvider to give to other consumers
	//Implies a flush
	Unlock()

	//Writes a slice to the segment, returns immediately
	//Returns nil if op is OK, otherwise ErrNoSpace or ErrInvalidArgument
	//It is up to the implementer to work out how to report no space immediately
	//The uint64 is the address to be used for the next write
	Write(uuid []byte, address uint64, data []byte) (uint64, error)

	//Block until all writes are complete. Note this does not imply a flush of the underlying files.
	Flush()
}

type StorageProvider

type StorageProvider interface {

	//Called at startup of a normal run
	Initialize(opts map[string]string)

	//Called to create the database for the first time
	//Note that initialize is not called before this function call
	//and you can assume the program will exit shortly after this
	//function call
	CreateDatabase(opts map[string]string) error

	// Lock a segment, or block until a segment can be locked
	// Returns a Segment struct
	LockSegment(uuid []byte) Segment

	// Read the blob into the given buffer
	Read(uuid []byte, address uint64, buffer []byte) []byte
}

Jump to

Keyboard shortcuts

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