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

paylog

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: 20 Imported by: 0

Documentation

Overview

Package paylog is a volume engine shell over a storage Device: block payloads append to a log of segment files, and one ordered index holds the key-value store, the block locations, and the garbage collection journal.

Every durable index commit also publishes the locations of the blocks written since the previous one. The commit's flush covers the earlier segment writes, so a published block is durable, and a key-value commit that follows a block write publishes that block with it. An ordered commit publishes no blocks, since a crash could keep its record and lose their payloads.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

type Index interface {
	kvtx.Store

	// Close releases the index. Uncommitted writes are lost.
	Close() error
}

Index is the ordered key-value index a Store keeps on its device. Read transactions see a snapshot and may stay open across commits. A write transaction excludes other writers, and its Commit applies atomically and makes every earlier write on the device durable no later than the commit itself, so a crash never keeps a commit without them. A write transaction may also implement kvtx.OrderedCommitTx, whose commits a device flush makes durable. The index keeps its own files on the device, none named with segmentPrefix.

func OpenBolt

func OpenBolt(ctx context.Context, dev device.Device) (Index, error)

OpenBolt opens the bbolt index on dev, creating it when dev has none.

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 Device with an ordered index.

func Open

func Open(ctx context.Context, dev device.Device, index Index) (*Store, error)

Open opens the store on dev with index, an index opened on the same device. The store owns the index and closes it on Close or on failure.

func (*Store) AppendJournal

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

AppendJournal durably journals reference graph changes in one index commit, which also publishes 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 index 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 closes the index. Unpublished 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 from one index view.

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 appends the payload to the open segment. The block is readable at once and durable after the next Sync or index commit.

func (*Store) PutBlockBatch

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

PutBlockBatch verifies every entry, then appends the new payloads in one device call and records 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 index 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, published by the next Sync or index commit.

func (*Store) StatBlock

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

StatBlock returns a block's payload length without reading it.

func (*Store) Sync

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

Sync publishes every pending block write and remove in one index commit, which also makes the earlier ordered commits durable. With nothing pending it flushes the device instead, which costs nothing when nothing is dirty.

Jump to

Keyboard shortcuts

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