refstore

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: AGPL-3.0 Imports: 5 Imported by: 7

Documentation

Overview

Package refstore persists reference records in a Pebble DB: name bytes → CBOR record bytes, stored verbatim. It is a dumb KV layer; record validation belongs to the daemon and the reference package.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("refstore: reference not found")

ErrNotFound is returned by Get and Delete for an absent name.

Functions

This section is empty.

Types

type Record

type Record struct {
	Name string
	Data []byte
}

Record is one (name, record-bytes) pair from All.

type Store

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

Store is a Pebble-backed name→record map. It is safe for concurrent use. Readers (Get, All) are lock-free; writes (Put, Delete) are serialized via writeMu so that Delete's existence check is linearizable against other writers.

func Open

func Open(dir string, sync bool) (*Store, error)

Open opens (creating if missing) the refs DB at dir. sync selects the write durability, matching the daemon's --sync flag.

func (*Store) All

func (s *Store) All() ([]Record, error)

All returns every record in lexicographic name order.

func (*Store) Close

func (s *Store) Close() error

Close closes the DB.

func (*Store) Delete

func (s *Store) Delete(name string) error

Delete removes name, or returns ErrNotFound if absent. The existence check and the delete are serialized against other writes via writeMu, so concurrent Deletes of the same name report ErrNotFound to all but one caller.

func (*Store) Get

func (s *Store) Get(name string) ([]byte, error)

Get returns the record stored under name, or ErrNotFound.

func (*Store) Put

func (s *Store) Put(name string, record []byte) error

Put stores record under name, overwriting unconditionally.

func (*Store) Wipe

func (s *Store) Wipe() error

Wipe deletes every record (the store-wipe operation). Iterate-and-delete rather than a range tombstone: names are arbitrary bytes so no literal upper bound covers the whole keyspace, and ref counts are small.

Jump to

Keyboard shortcuts

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