stupid

package
v0.0.0-...-8beb243 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// IDTypeTLV is the type of the ID TLV
	IDTypeTLV = byte(1)

	// OpTypeTLV is the type of the operation TLV.
	OpTypeTLV = byte(2)

	// KeyTypeTLV is the type of the key TLV.
	KeyTypeTLV = byte(3)

	// ValTypeTLV is the type of the value TLV.
	ValTypeTLV = byte(4)
)

Variables

View Source
var (
	// Storage Ops
	SetOp = byte(1)
	DelOp = byte(2)
)

Functions

This section is empty.

Types

type Packet

type Packet struct {
	ID  uint64
	Op  byte
	Key []byte
	Val []byte
	// contains filtered or unexported fields
}

Packet is the basic unit of data transfer between the engine and the file system.

type Storage

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

Storage is a stupid storage.

func New

func New(dir string, cfg config.Config) *Storage

New returns a new Storage instance.

func (*Storage) Close

func (s *Storage) Close() error

Close closes the storage.

func (*Storage) Delete

func (s *Storage) Delete(key []byte) error

Delete deletes the value for the given key.

func (*Storage) DetectAndFix

func (s *Storage) DetectAndFix() error

DetectAndFix detects corrupt data in the store and tries to fix it

Note: DetectAndFix will remove the corrupt data from the store which means that some of the writes might vanish. But this is same because the storage engine provides guaranatees only in the cases when it is running in the sync mode and a response is sent back to the client indicating a success.

func (*Storage) Exists

func (s *Storage) Exists(key []byte) (bool, error)

Exists returns true if the given key exists.

func (*Storage) ForEach

func (s *Storage) ForEach(fn func(*reader, *Packet, error) error) error

ForEach goes through the entire store and executes the given function on each packet that it reads.

func (*Storage) Get

func (s *Storage) Get(key []byte) ([]byte, error)

Get returns the value for the given key.

func (*Storage) GetByID

func (s *Storage) GetByID(id uint64) (*Packet, error)

GetByID returns a packet corresponding to the given ID.

This is a low level API and should not be used by the user.

func (*Storage) Init

func (s *Storage) Init() error

Init configures the storage.

func (*Storage) Len

func (s *Storage) Len() (int, error)

Len returns the number of keys in the storage.

func (*Storage) PhysicalSnapshot

func (s *Storage) PhysicalSnapshot(w io.Writer) error

PhysicalSnapshot writes the current state of the storage to the given writer. The snapshot is written in a format that can be read by only by the storage.

Note: The DB is locked for writes while the snapshot is being generated.

func (*Storage) Set

func (s *Storage) Set(key []byte, value []byte) error

Set sets the value for the given key.

Jump to

Keyboard shortcuts

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