Documentation ¶
Index ¶
- Variables
- func MetadataFromCallOptions(opts ...CallOption) metadata.MD
- type CallOption
- type Client
- type Collection
- type Dictionary
- type Mutex
- type Option
- func WithBootstrap(v string) Option
- func WithCallOptions(v ...grpc.CallOption) Option
- func WithDialTimeout(v time.Duration) Option
- func WithFailFast(v bool) Option
- func WithID(v []byte) Option
- func WithIdleStrategy(v cc.IdleStrategy) Option
- func WithKeepAlivePeriod(v time.Duration) Option
- func WithLoggerName(v string) Option
- func WithLoggingLevel(v string) Option
- func WithPingPeriod(v time.Duration) Option
- func WithRetryTimeout(v time.Duration) Option
- type Queue
- type State
- type StateChan
Constants ¶
This section is empty.
Variables ¶
var ErrNotReady = errors.New("client not ready")
ErrNotReady is the error returned by client.Ready when the client is not ready.
var TimeNowInMillis = func() int64 { return time.Now().UnixNano() / int64(time.Millisecond) }
TimeNowInMillis returns current time in milliseconds.
Functions ¶
func MetadataFromCallOptions ¶
func MetadataFromCallOptions(opts ...CallOption) metadata.MD
MetadataFromCallOptions creates gRPC metadata from call options.
Types ¶
type CallOption ¶
type CallOption func(*callOptions)
CallOption adds an option to a method call.
func WithBarrier ¶
func WithBarrier() CallOption
WithBarrier is used to block a call until all preceding have been applied to the Raft Cluster.
func WithWaitingBarrier ¶
func WithWaitingBarrier(d time.Duration) CallOption
WithWaitingBarrier is used to block a call until all preceding have been applied to the Raft Cluster. An optional timeout limits the amount of time we wait for the command to be started.
type Client ¶
type Client interface { // Queue returns a Queue with the name n. Queue(n string) Queue // Dictionary returns a Dictionary with the name n. Dictionary(n string) Dictionary // Mutex returns a Mutex with the name n. Mutex(n string) Mutex // State returns a channel which reports the Client state changes. State() StateChan }
Client defines Stoa client methods.
type Collection ¶
type Collection interface { // Name returns the Collection name Name() string // Size returns the collection size Size(ctx context.Context, opts ...CallOption) (uint32, error) // Clear clears the collection Clear(ctx context.Context, opts ...CallOption) error }
Collection is a generic collection
type Dictionary ¶
type Dictionary interface { Collection // Put puts a new key-value pair into the dictionary. // If the key already exists overwrites the existing value with the new one. // Returns the previous value associated with key, or nil if there was no mapping // for key. Put(ctx context.Context, k, v []byte, opts ...CallOption) ([]byte, error) // PutIfAbsent puts the key-value pair (and returns true) // only if the key is absent, otherwise it returns false. PutIfAbsent(ctx context.Context, k, v []byte, opts ...CallOption) (bool, error) // Get returns the value specified by the key if the key-value pair is // present, othervise returns nil. Get(ctx context.Context, k []byte, opts ...CallOption) ([]byte, error) // Remove removes the key-value pair specified by the key k from the map // if it is present. Remove(ctx context.Context, k []byte, opts ...CallOption) error // Range returns the channel kv that will send all key-value pairs containing in // the dictionary. Range(ctx context.Context, opts ...CallOption) (kv <-chan [][]byte, err <-chan error) }
Dictionary represents a collection of key-value pairs.
type Mutex ¶
type Mutex interface { // TryLock tries to lock the Mutex. Returns true on success, otherwise // returns false. TryLock(ctx context.Context, payload []byte, opts ...CallOption) (bool, []byte, error) // Unlock tries to unlock the Mutex. Returns true if the locked Mutex was // unlocked, otherwise returns false. Unlock(ctx context.Context, opts ...CallOption) (bool, []byte, error) }
Mutex is a mutual exclusion lock.
type Option ¶
type Option func(*client)
Option is a function applied to an options to change the options' default values.
func WithBootstrap ¶
WithBootstrap sets the Cluster peers to connect to.
func WithCallOptions ¶
func WithCallOptions(v ...grpc.CallOption) Option
WithCallOptions sets gRPC call options.
func WithDialTimeout ¶
WithDialTimeout changes the default gRPC dial timeout.
func WithFailFast ¶
WithFailFast enables or disables (disabled by default) the Client's fail fast option. If enabled the Client does not retry unsuccessful Cluster calls.
func WithIdleStrategy ¶
func WithIdleStrategy(v cc.IdleStrategy) Option
WithIdleStrategy sets the Client's idle stratege.
func WithKeepAlivePeriod ¶
WithKeepAlivePeriod sets the Client's gRPC keep alive period.
func WithLoggerName ¶
WithLoggerName sets the Client's logger name.
func WithLoggingLevel ¶
WithLoggingLevel sets the Client's logging level.
func WithPingPeriod ¶
WithPingPeriod sets the period between ping messages sent by the Client to the Cluster.
func WithRetryTimeout ¶
WithRetryTimeout defines the timeout to retry the call to the Cluster within.
type Queue ¶
type Queue interface { Collection // Offer inserts the element e into the queue Offer(ctx context.Context, e []byte, opts ...CallOption) error // Poll retrieves and removes the head of the queue; returns nil if the queue is empty Poll(ctx context.Context, opts ...CallOption) ([]byte, error) // Peek retrieves, but does not remove, the head of the queue; returns nil if the queue is empty Peek(ctx context.Context, opts ...CallOption) ([]byte, error) }
Queue defines ordered in FIFO manner collection of elements which may contain duplicates