fs

package
v0.0.0-...-d12bbc4 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package fs provides a simple filesystem log storage implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadCheckpoint

func ReadCheckpoint(rootDir string) ([]byte, error)

ReadCheckpoint reads and returns the contents of the log checkpoint file.

Types

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

Storage is a serverless storage implementation which uses files to store tree state. The on-disk structure is:

<rootDir>/leaves/aa/bb/cc/ddeeff...
<rootDir>/leaves/pending/aabbccddeeff...
<rootDir>/seq/aa/bb/cc/ddeeff...
<rootDir>/tile/<level>/aa/bb/ccddee...
<rootDir>/checkpoint

The functions on this struct are not thread-safe.

func Create

func Create(rootDir string) (*Storage, error)

Create creates a new filesystem hierarchy and returns a Storage representation for it.

func Load

func Load(rootDir string, cpSize uint64) (*Storage, error)

Load returns a Storage instance initialised from the filesystem at the provided location. cpSize should be the Size of the checkpoint produced from the last `log.Integrate` call.

func (*Storage) Assign

func (fs *Storage) Assign(_ context.Context, seq uint64, leaf []byte) error

Assign directly associates the given leaf data with the provided sequence number. It is an error to attempt to assign data to a previously assigned sequence number, even if the data is identical.

func (*Storage) GetTile

func (fs *Storage) GetTile(_ context.Context, level, index, logSize uint64) (*api.Tile, error)

GetTile returns the tile at the given tile-level and tile-index. If no complete tile exists at that location, it will attempt to find a partial tile for the given tree size at that location.

func (*Storage) ScanSequenced

func (fs *Storage) ScanSequenced(_ context.Context, begin uint64, f func(seq uint64, entry []byte) error) (uint64, error)

ScanSequenced calls the provided function once for each contiguous entry in storage starting at begin. The scan will abort if the function returns an error, otherwise it will return the number of sequenced entries.

func (*Storage) Sequence

func (fs *Storage) Sequence(ctx context.Context, leafhash []byte, leaf []byte) (uint64, error)

Sequence assigns the given leaf entry to the next available sequence number. This method will attempt to silently squash duplicate leaves, but it cannot be guaranteed that no duplicate entries will exist. Returns the sequence number assigned to this leaf (if the leaf has already been sequenced it will return the original sequence number and ErrDupeLeaf).

func (*Storage) StoreTile

func (fs *Storage) StoreTile(_ context.Context, level, index uint64, tile *api.Tile) error

StoreTile writes a tile out to disk. Fully populated tiles are stored at the path corresponding to the level & index parameters, partially populated (i.e. right-hand edge) tiles are stored with a .xx suffix where xx is the number of "tile leaves" in hex.

func (Storage) WriteCheckpoint

func (fs Storage) WriteCheckpoint(_ context.Context, newCPRaw []byte) error

WriteCheckpoint stores a raw log checkpoint on disk.

Jump to

Keyboard shortcuts

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