predicate

package
v0.0.0-...-c36b4a8 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: BSD-2-Clause Imports: 0 Imported by: 0

Documentation

Overview

Package predicate provides types and interfaces for conditional operations. It defines predicate logic used in transactional conditional execution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Op

type Op int

Op represents the comparison operation type for predicates.

const (
	// OpEqual represents equality comparison.
	OpEqual Op = iota
	// OpNotEqual represents inequality comparison.
	OpNotEqual
	// OpGreater represents greater than comparison.
	OpGreater
	// OpLess represents less than comparison.
	OpLess
)

func (Op) String

func (op Op) String() string

type Predicate

type Predicate interface {
	// Key returns the key that this predicate applies to.
	Key() []byte
	// Operation returns the comparison operation (Equal, NotEqual, Greater, Less).
	Operation() Op
	// Target returns what aspect of the key to compare (Version, Value).
	Target() Target
	// Value returns the comparison value for the predicate.
	Value() any
}

Predicate represents a condition used for conditional operations. Predicates are used in transactions to specify conditions for execution.

func ValueEqual

func ValueEqual(key []byte, value any) Predicate

ValueEqual creates a predicate that checks if a key's value equals the specified value.

func ValueNotEqual

func ValueNotEqual(key []byte, value any) Predicate

ValueNotEqual creates a predicate that checks if a key's value is not equal to the specified value.

func VersionEqual

func VersionEqual(key []byte, version int64) Predicate

VersionEqual creates a predicate that checks if a key's version equals the specified version.

func VersionGreater

func VersionGreater(key []byte, version int64) Predicate

VersionGreater creates a predicate that checks if a key's version is greater than the specified version.

func VersionLess

func VersionLess(key []byte, version int64) Predicate

VersionLess creates a predicate that checks if a key's version is less than the specified version.

func VersionNotEqual

func VersionNotEqual(key []byte, version int64) Predicate

VersionNotEqual creates a predicate that checks if a key's version is not equal to the specified version.

type Target

type Target int

Target represents what aspect of a key to compare in predicates.

const (
	// TargetVersion compares the version of the key.
	TargetVersion Target = iota
	// TargetValue compares the value of the key.
	TargetValue
)

func (Target) String

func (t Target) String() string

Jump to

Keyboard shortcuts

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