set

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: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Type primitive.Type = "Set"

Type is the set type

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides an API for creating Sets

type Event

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

	// Value is the value that changed
	Value string
}

Event is a set change event

type EventType

type EventType string

EventType is the type of a set event

const (
	// EventAdd indicates a value was added to the set
	EventAdd EventType = "add"

	// EventRemove indicates a value was removed from the set
	EventRemove EventType = "remove"

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

type Option

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

Option is a set option

type Set

type Set interface {
	primitive.Primitive

	// Add adds a value to the set
	Add(ctx context.Context, value string) (bool, error)

	// Remove removes a value from the set
	// A bool indicating whether the set contained the given value will be returned
	Remove(ctx context.Context, value string) (bool, error)

	// Contains returns a bool indicating whether the set contains the given value
	Contains(ctx context.Context, value string) (bool, error)

	// Len gets the set size in number of elements
	Len(ctx context.Context) (int, error)

	// Clear removes all values from the set
	Clear(ctx context.Context) error

	// Elements lists the elements in the set
	Elements(ctx context.Context, ch chan<- string) error

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

Set provides a distributed set data structure The set values are defines as strings. To store more complex types in the set, encode values to strings e.g. using base 64 encoding.

func New

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

New creates a new partitioned set primitive

type WatchOption

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

WatchOption is an option for set Watch calls

func WithReplay

func WithReplay() WatchOption

WithReplay returns a Watch option to replay entries

Jump to

Keyboard shortcuts

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