storage

package
v0.0.0-...-e9451bc Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const MaxStaleness = time.Duration(math.MaxInt64)

Variables

View Source
var ErrKeyNotFound = errors.New("key not found in committed transaction")

Functions

This section is empty.

Types

type Global

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

func NewGlobal

func NewGlobal(b backend.Backend, l Local, clock clockwork.Clock) Global

func (Global) Delete

func (s Global) Delete(ctx context.Context, key string) error

func (Global) DeleteIf

func (s Global) DeleteIf(ctx context.Context, key string, expected backend.Version) error

func (Global) GetMetadata

func (s Global) GetMetadata(ctx context.Context, key string) (backend.Metadata, error)

func (Global) Read

func (s Global) Read(ctx context.Context, key string) (GlobalRead, error)

func (Global) SetTagsIf

func (s Global) SetTagsIf(
	ctx context.Context,
	key string,
	expected backend.Version,
	t backend.Tags,
) (backend.Metadata, error)

func (Global) Write

func (s Global) Write(
	ctx context.Context,
	key string,
	value []byte,
	t backend.Tags,
) (backend.Metadata, error)

func (Global) WriteIf

func (s Global) WriteIf(
	ctx context.Context,
	key string,
	value []byte,
	expected backend.Version,
	t backend.Tags,
) (backend.Metadata, error)

func (Global) WriteIfNotExists

func (s Global) WriteIfNotExists(
	ctx context.Context,
	key string,
	value []byte,
	t backend.Tags,
) (backend.Metadata, error)

type GlobalRead

type GlobalRead struct {
	Value   []byte
	Version int64
}

type Local

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

func NewLocal

func NewLocal(c *cache.Cache, clock clockwork.Clock) Local

func (Local) Delete

func (c Local) Delete(key string)

func (Local) GetMeta

func (c Local) GetMeta(key string, maxStale time.Duration) (LocalMetadata, bool)

func (Local) MarkDeleted

func (c Local) MarkDeleted(key string, v Version)

func (Local) MarkValueOutated

func (c Local) MarkValueOutated(key string, v Version)

MarkStale annotates the given key value as outdated, only if it's currently set at the given version.

func (Local) Read

func (c Local) Read(key string, maxStale time.Duration) (LocalRead, bool)

func (Local) SetMeta

func (c Local) SetMeta(key string, meta backend.Metadata)

func (Local) Write

func (c Local) Write(key string, value []byte, v Version)

func (Local) WriteWithMeta

func (c Local) WriteWithMeta(key string, value []byte, meta backend.Metadata)

type LocalMetadata

type LocalMetadata struct {
	M backend.Metadata
	// Outdated is true if the metadata is certainly outdated.
	Outdated bool
}

type LocalRead

type LocalRead struct {
	Value   []byte
	Version Version
	Deleted bool
	// Outdated is true if the value read is certainly outdated.
	Outdated bool
}

type LockInfo

type LockInfo struct {
	Type       LockType
	LockedBy   []data.TxID
	LastWriter data.TxID
}

func TagsLockInfo

func TagsLockInfo(tags backend.Tags) (LockInfo, error)

TagsLockInfo parses tags managing locks on an object.

func (LockInfo) Valid

func (v LockInfo) Valid() error

type LockOps

type LockOps struct {
	// Update is the possible next update on the lock. If nothing should be
	// updated, HasUpdate will be false.
	Update    LockUpdate
	HasUpdate bool
	// WaitFor is the list of transactions that need to unlock before any
	// operation can be performed.
	WaitFor []data.TxID
	// What effect these operations will have.
	LockedFor   []data.TxID
	UnlockedFor []data.TxID
}

LockOps represents what possible next update can be done to a lock.

This includes the update, what transactions need to unlock before this can done and what effects the operation will have.

func ComputeLockUpdate

func ComputeLockUpdate(curr LockInfo, req LockRequest, txs []TxPathState) (LockOps, error)

type LockRequest

type LockRequest struct {
	Type      LockType
	Lockers   []data.TxID
	Unlockers []data.TxID
}

type LockType

type LockType int
const (
	LockTypeUnknown LockType = iota
	LockTypeNone
	LockTypeRead
	LockTypeWrite
	LockTypeCreate
)

type LockUpdate

type LockUpdate struct {
	Type     LockType
	PrevType LockType
	Lockers  []data.TxID
	Writer   data.TxID
	Value    TValue
}

type Locker

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

func NewLocker

func NewLocker(g Global) Locker

func (Locker) UnlockCreateUncommitted

func (l Locker) UnlockCreateUncommitted(
	ctx context.Context,
	key string,
	expected backend.Version,
) error

func (Locker) UpdateLock

func (l Locker) UpdateLock(
	ctx context.Context,
	key string,
	expected backend.Version,
	update LockUpdate,
) error

type PathLock

type PathLock struct {
	Path string
	Type LockType
}

type TLogger

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

TLogger provides tools to deal with transaction logs.

func NewTLogger

func NewTLogger(c clockwork.Clock, g Global, l Local, prefix string) TLogger

func (TLogger) CommitStatus

func (t TLogger) CommitStatus(ctx context.Context, id data.TxID) (TxStatus, error)

func (TLogger) Delete

func (t TLogger) Delete(ctx context.Context, id data.TxID) error

func (TLogger) Get

func (t TLogger) Get(ctx context.Context, id data.TxID) (TxLog, error)

func (TLogger) Set

func (t TLogger) Set(ctx context.Context, l TxLog) (backend.Version, error)

func (TLogger) SetIf

func (t TLogger) SetIf(ctx context.Context, l TxLog, expected backend.Version) (backend.Version, error)

type TValue

type TValue struct {
	Value   []byte
	Deleted bool
	// NotWritten is true when the transaction was committed but the value
	// was not written to (e.g. when only locked in read).
	NotWritten bool
}

type TxCommitStatus

type TxCommitStatus int
const (
	TxCommitStatusUnknown TxCommitStatus = iota
	TxCommitStatusOK
	TxCommitStatusAborted
	TxCommitStatusPending
)

func (TxCommitStatus) IsFinal

func (s TxCommitStatus) IsFinal() bool

type TxLog

type TxLog struct {
	ID        data.TxID
	Timestamp time.Time
	Status    TxCommitStatus
	Writes    []TxWrite
	Locks     []PathLock
}

type TxPathState

type TxPathState struct {
	Tx     data.TxID
	Status TxCommitStatus
	Value  TValue
}

type TxStatus

type TxStatus struct {
	Status     TxCommitStatus
	LastUpdate time.Time
	Version    backend.Version
}

type TxWrite

type TxWrite struct {
	Path       string
	Value      []byte
	Deleted    bool
	PrevWriter data.TxID
}

type Version

type Version struct {
	B      backend.Version
	Writer data.TxID
}

func VersionFromMeta

func VersionFromMeta(m backend.Metadata) Version

func (Version) EqualContents

func (v Version) EqualContents(other Version) bool

func (Version) EqualMetaContents

func (v Version) EqualMetaContents(m backend.Metadata) bool

func (Version) IsLocal

func (v Version) IsLocal() bool

func (Version) IsNull

func (v Version) IsNull() bool

Jump to

Keyboard shortcuts

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