value

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const Type primitive.Type = "Value"

Type is the value type

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// GetValue gets the Value instance of the given name
	GetValue(ctx context.Context, name string) (Value, error)
}

Client provides an API for creating Values

type Event

type Event struct {
	// Type is the change event type
	Type EventType

	// Value is the updated value
	Value []byte

	// Version is the updated version
	Version uint64
}

Event is a value change event

type EventType

type EventType string

EventType is the type of a set event

const (
	// EventUpdated indicates the value was updated
	EventUpdated EventType = "updated"
)

type SetOption

type SetOption interface {
	// contains filtered or unexported methods
}

SetOption is an option for Set calls

func IfValue

func IfValue(value []byte) SetOption

IfValue updates the value if the current value matches the given value

func IfVersion

func IfVersion(version uint64) SetOption

IfVersion updates the value if the version matches the given version

type Value

type Value interface {
	primitive.Primitive

	// Set sets the current value and returns the version
	Set(ctx context.Context, value []byte, opts ...SetOption) (uint64, error)

	// Get gets the current value and version
	Get(ctx context.Context) ([]byte, uint64, error)

	// Watch watches the value for changes
	Watch(ctx context.Context, ch chan<- *Event) error
}

Value provides a simple atomic value

func New

func New(ctx context.Context, name primitive.Name, partitions []*primitive.Session) (Value, error)

New creates a new Lock primitive for the given partitions The value will be created in one of the given partitions.

Jump to

Keyboard shortcuts

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