Documentation
¶
Index ¶
Constants ¶
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
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 GetOption ¶
type GetOption interface {
// contains filtered or unexported methods
}
GetOption is an option for the Get method
func WithDefault ¶
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
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
type PutOption ¶
type PutOption interface {
// contains filtered or unexported methods
}
PutOption is an option for the Put method
type RemoveOption ¶
type RemoveOption interface {
// contains filtered or unexported methods
}
RemoveOption is an option for the Remove method
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