_map

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: 11 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 ...Option) (Map, error)
}

Client provides an API for creating Maps

type Entry

type Entry struct {
	// Version is the unique, monotonically increasing version number for the key/value pair. The version is
	// suitable for use in optimistic locking.
	Version Version

	// Key is the key of the pair
	Key string

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

	// Created is the time at which the key was created
	Created time.Time

	// Updated is the time at which the key was last updated
	Updated time.Time
}

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 (
	// EventNone indicates the event is not a change event
	EventNone EventType = ""

	// EventInserted indicates a key was newly created in the map
	EventInserted EventType = "inserted"

	// EventUpdated indicates the value of an existing key was changed
	EventUpdated EventType = "updated"

	// EventRemoved indicates a key was removed from the map
	EventRemoved EventType = "removed"
)

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

func WithDefault

func WithDefault(def []byte) GetOption

WithDefault sets the default value to return if the key is not present

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 primitive.Name, sessions []*primitive.Session, opts ...Option) (Map, error)

New creates a new partitioned Map

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 {
	// contains filtered or unexported methods
}

Option is an option for a Map instance

func WithCache

func WithCache(size int) Option

WithCache returns an option that enables caching for a Map

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 added in v0.3.0

type Version uint64

Version is an entry version

type VersionOption

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

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

func IfVersion

func IfVersion(version Version) VersionOption

IfVersion sets the required version for optimistic concurrency control

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