_map

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const Type primitive.Type = "Map"

Type is the map type

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// GetMap gets the Map instance of the given name
	GetMap(ctx context.Context, name string, opts ...primitive.Option) (Map, error)
}

Client provides an API for creating Maps

type Entry

type Entry struct {
	meta.ObjectMeta

	// Key is the key of the pair
	Key string

	// Value is the value of the pair
	Value []byte
}

Entry is a versioned key/value pair

func (Entry) String

func (kv Entry) String() string

type Event

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

	// Entry is the event entry
	Entry Entry
}

Event is a map change event

type EventType

type EventType string

EventType is the type of a map event

const (
	// EventInsert indicates a key was newly created in the map
	EventInsert EventType = "insert"

	// EventUpdate indicates the value of an existing key was changed
	EventUpdate EventType = "update"

	// EventRemove indicates a key was removed from the map
	EventRemove EventType = "remove"

	// EventReplay indicates a key was replayed
	EventReplay EventType = "replay"
)

type Filter

type Filter struct {
	Key string
}

Filter is a watch filter configuration

type GetOption

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

GetOption is an option for the Get method

type Map

type Map interface {
	primitive.Primitive

	// Put sets a key/value pair in the map
	Put(ctx context.Context, key string, value []byte, opts ...PutOption) (*Entry, error)

	// Get gets the value of the given key
	Get(ctx context.Context, key string, opts ...GetOption) (*Entry, error)

	// Remove removes a key from the map
	Remove(ctx context.Context, key string, opts ...RemoveOption) (*Entry, error)

	// Len returns the number of entries in the map
	Len(ctx context.Context) (int, error)

	// Clear removes all entries from the map
	Clear(ctx context.Context) error

	// Entries lists the entries in the map
	// This is a non-blocking method. If the method returns without error, key/value paids will be pushed on to the
	// given channel and the channel will be closed once all entries have been read from the map.
	Entries(ctx context.Context, ch chan<- Entry) error

	// Watch watches the map for changes
	// This is a non-blocking method. If the method returns without error, map events will be pushed onto
	// the given channel in the order in which they occur.
	Watch(ctx context.Context, ch chan<- Event, opts ...WatchOption) error
}

Map is a distributed set of keys and values

func New

func New(ctx context.Context, name string, conn *grpc.ClientConn, opts ...primitive.Option) (Map, error)

New creates a new partitioned Map

type MatchOption

type MatchOption struct {
	PutOption
	RemoveOption
	// contains filtered or unexported fields
}

MatchOption is an implementation of PutOption and RemoveOption to specify the version for concurrency control

func IfMatch

func IfMatch(object meta.Object) MatchOption

IfMatch sets the required version for optimistic concurrency control

type NotSetOption

type NotSetOption struct {
}

NotSetOption is a PutOption that sets the value only if it's not already set

type Option

type Option interface {
	primitive.Option
	// contains filtered or unexported methods
}

Option is a map option

type PutOption

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

PutOption is an option for the Put method

func IfNotSet

func IfNotSet() PutOption

IfNotSet sets the value if the entry is not yet set

type RemoveOption

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

RemoveOption is an option for the Remove method

type Version

type Version uint64

Version is an entry version

type WatchOption

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

WatchOption is an option for the Watch method

func WithFilter

func WithFilter(filter Filter) WatchOption

WithFilter returns a watch option that filters the watch events

func WithReplay

func WithReplay() WatchOption

WithReplay returns a watch option that enables replay of watch events

Jump to

Keyboard shortcuts

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