memlog

package
v0.0.0-...-afa4d9b Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: LGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemFileStore

type MemFileStore struct {
	*MemStore
	// contains filtered or unexported fields
}

MemFileStore is just like MemStore, but with node data backed by the file system. Only the node metadata will be kept in memory and in the append-only logs, while the node data itself will be saved to disk, in files named after each node's path.

The result is that MemFileStore produces a file hierarchy that matches exactly what is in the database, and can thus be used by external programs.

func NewMemFileStore

func NewMemFileStore(path string) (*MemFileStore, error)

NewMemFileStore creates a new MemFileStore based at 'path'. The database will be stored in a subdirectory of path called '.db'.

func (*MemFileStore) AddNode

func (m *MemFileStore) AddNode(node *pb.Node) (bool, error)

func (*MemFileStore) TreeDiff

func (m *MemFileStore) TreeDiff(summary *pb.NodeStateSummary, prefix string) []*pb.Node

type MemStore

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

MemStore is an in-memory database of Node objects, indexed by their path. It utilizes a radix tree (compressed trie) to organize the nodes, so that scanning by path prefix is fast.

In-memory data is persisted to disk using an append-only log, checkpointed on startup and auto-rotated.

func NewMemStore

func NewMemStore(path string) (*MemStore, error)

NewMemStore returns a MemStore backed by an append-only log at the specified path (which must be a directory). The log directory is created if it does not exist.

func (*MemStore) AddNode

func (m *MemStore) AddNode(node *pb.Node) (bool, error)

AddNode adds a node to the database. Attempts to add nodes which have newer versions in the database will be ignored. The function returns true if the database was actually modified.

func (*MemStore) Close

func (m *MemStore) Close()

Close the data store and all its associated resources.

func (*MemStore) Summary

func (m *MemStore) Summary() *pb.NodeStateSummary

Summary returns a NodeStateSummary with all the metadata of the Node objects in the database.

func (*MemStore) TreeDiff

func (m *MemStore) TreeDiff(summary *pb.NodeStateSummary, prefix string) []*pb.Node

TreeDiff compares part (or all) of the database with a summary, and returns all the nodes contained in the database which are missing in the summary.

Jump to

Keyboard shortcuts

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