Help us shape the future of Go! Take the 2026 Go Developer Survey

direct

package
v0.57.21 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package direct is a volume engine that stores every key-value entry, block, and journal entry as its own record in a records.Store, the shape of an IndexedDB object store.

The key-value store and the journal also live in a memtable loaded at Open, so reads never reach the record store. Each write transaction commits as one record store call carrying its changes and the block writes and removes made since the previous commit. Record store calls apply atomically and in order, so an ordered commit may publish blocks too: a crash that keeps it keeps every call before it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	// kvtx.Store serves the key-value store under kvPrefix.
	kvtx.Store
	// contains filtered or unexported fields
}

Store is a volume engine on a record store.

func Open

func Open(ctx context.Context, rs records.Store) (*Store, error)

Open opens the store on rs, loading the key-value store and the journal.

func (*Store) AppendJournal

func (s *Store) AppendJournal(ctx context.Context, adds, removes []block_gc.RefEdge) error

AppendJournal durably journals reference graph changes in one commit, which also commits the pending blocks.

func (*Store) AppendJournalOrdered

func (s *Store) AppendJournalOrdered(ctx context.Context, adds, removes []block_gc.RefEdge) error

AppendJournalOrdered journals reference graph changes in one ordered commit, which the next Sync or durable commit makes durable.

func (*Store) BeginReadOperation

func (s *Store) BeginReadOperation(context.Context) (block.StoreOps, func(), error)

BeginReadOperation returns the store, which needs no read scope.

func (*Store) Close

func (s *Store) Close() error

Close releases the store. Uncommitted block writes are lost.

func (*Store) GetBlock

func (s *Store) GetBlock(ctx context.Context, ref *block.BlockRef) ([]byte, bool, error)

GetBlock reads a block's payload.

func (*Store) GetBlockExists

func (s *Store) GetBlockExists(ctx context.Context, ref *block.BlockRef) (bool, error)

GetBlockExists checks whether a block is stored.

func (*Store) GetBlockExistsBatch

func (s *Store) GetBlockExistsBatch(ctx context.Context, refs []*block.BlockRef) ([]bool, error)

GetBlockExistsBatch checks each reference in one record store call.

func (*Store) GetHashType

func (s *Store) GetHashType() hash.HashType

GetHashType returns zero to select the default hash type.

func (*Store) GetStoredBlock

func (s *Store) GetStoredBlock(ctx context.Context, ref *block.BlockRef) (*block.StoredBlock, error)

GetStoredBlock serves the block without refs because this store keeps block bytes without their refs.

func (*Store) GetSupportedFeatures

func (s *Store) GetSupportedFeatures() block.StoreFeature

GetSupportedFeatures reports native batches and the store's own buffering.

func (*Store) PutBlock

func (s *Store) PutBlock(ctx context.Context, data []byte, opts *block.PutOpts) (*block.BlockRef, bool, error)

PutBlock adds the payload to the pending blocks. The block is readable at once and durable after the next Sync or durable commit.

func (*Store) PutBlockBatch

func (s *Store) PutBlockBatch(ctx context.Context, entries []*block.PutBatchEntry) error

PutBlockBatch verifies every entry, then adds the new payloads and the tombstones as removes.

func (*Store) ReplayJournal

func (s *Store) ReplayJournal(ctx context.Context, apply func(adds, removes []block_gc.RefEdge) error) error

ReplayJournal passes every journal entry in order to apply and removes the entries in one durable commit, skipping the commit when the journal is empty.

func (*Store) RmBlock

func (s *Store) RmBlock(ctx context.Context, ref *block.BlockRef) error

RmBlock records a pending remove, committed by the next Sync or commit.

func (*Store) StatBlock

func (s *Store) StatBlock(ctx context.Context, ref *block.BlockRef) (*block.BlockStat, error)

StatBlock returns a block's payload length. A record store keeps no length apart from the payload, so it reads the payload.

func (*Store) Sync

func (s *Store) Sync(ctx context.Context) (bool, error)

Sync commits the pending block writes and removes durably in one record store call, which also makes the earlier ordered commits durable. It holds the table's writer lock, since the table's commits must not overlap.

Jump to

Keyboard shortcuts

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