cindex

package
v3.0.0-...-97acc46 Latest Latest
Warning

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

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

Documentation

Overview

Package cindex provides an interface and implementation for getting/saving consistentIndex.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMetaBucket

func CreateMetaBucket(tx backend.BatchTx)

CreateMetaBucket creates the `meta` bucket (if it does not exists yet).

func ReadConsistentIndex

func ReadConsistentIndex(tx backend.ReadTx) (uint64, uint64)

ReadConsistentIndex loads consistent index and term from given transaction. returns 0 if the data are not found.

func UnsafeCreateMetaBucket

func UnsafeCreateMetaBucket(tx backend.BatchTx)

UnsafeCreateMetaBucket creates the `meta` bucket (if it does not exists yet).

func UnsafeUpdateConsistentIndex

func UnsafeUpdateConsistentIndex(tx backend.BatchTx, index uint64, term uint64)

func UpdateConsistentIndex

func UpdateConsistentIndex(tx backend.BatchTx, index uint64, term uint64)

Types

type Backend

type Backend interface {
	BatchTx() backend.BatchTx
	ReadTx() backend.ReadTx
}

type ConsistentIndexer

type ConsistentIndexer interface {

	// ConsistentIndex returns the consistent index of current executing entry.
	ConsistentIndex() uint64

	// ConsistentApplyingIndex returns the consistent applying index of current executing entry.
	ConsistentApplyingIndex() (uint64, uint64)

	// UnsafeConsistentIndex is similar to ConsistentIndex, but it doesn't lock the transaction.
	UnsafeConsistentIndex() uint64

	// SetConsistentIndex set the consistent index of current executing entry.
	SetConsistentIndex(v uint64, term uint64)

	// SetConsistentApplyingIndex set the consistent applying index of current executing entry.
	SetConsistentApplyingIndex(v uint64, term uint64)

	// UnsafeSave must be called holding the lock on the tx.
	// It saves consistentIndex to the underlying stable storage.
	UnsafeSave(tx backend.BatchTx)

	// SetBackend set the available backend.BatchTx for ConsistentIndexer.
	SetBackend(be Backend)
}

ConsistentIndexer is an interface that wraps the Get/Set/Save method for consistentIndex.

func NewConsistentIndex

func NewConsistentIndex(be Backend) ConsistentIndexer

NewConsistentIndex creates a new consistent index. If `be` is nil, it must be set (SetBackend) before first access using `ConsistentIndex()`.

func NewFakeConsistentIndex

func NewFakeConsistentIndex(index uint64) ConsistentIndexer

Jump to

Keyboard shortcuts

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