Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type Connection
- func (c *Connection) Close() error
- func (c *Connection) GetIterator(ctx context.Context, options ...IterOption) (*Iterator, error)
- func (c *Connection) GetLatest(ctx context.Context, key string) (Triplet, error)
- func (c *Connection) Put(ctx context.Context, key string, value string) (Triplet, error)
- type IterOption
- type Iterator
- type Option
- type Triplet
- type Version
Constants ¶
const DefaultBatchSize = 1000
DefaultBatchSize limits the maximum number of fetched items at a time. Such a limit is required to make network communication less loaded and escape gRPC message size limits.
Variables ¶
var ( // You are trying to get a next item from the finished iterator. ErrIterationFinished = errors.New("iteration finished") )
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func Open ¶
func Open(options ...Option) (conn *Connection, err error)
Open creates a new database connection. It takes a list of options to customize settings. See config_options.go for more details.
func (*Connection) Close ¶
func (c *Connection) Close() error
Close closes internal connection with the server and cleans resources. It only returns nil in the current implementation.
The connection cannot be used after Close was called.
func (*Connection) GetIterator ¶
func (c *Connection) GetIterator(ctx context.Context, options ...IterOption) (*Iterator, error)
GetIterator creates an iterator to iterate over values that satisfy the provided options.
See the iterator.go file to get list of available filters: - IterKeyEquals - IterFromVersion - IterSetLimit
type IterOption ¶
IterOption configures an iterator. At the moment you can use only already written options.
func IterFromVersion ¶
func IterFromVersion(version Version) IterOption
When IterFromVersion is provided, all yielded triplets have version greater than the given one.
By default there is no lower bound on allowed version.
func IterKeyEquals ¶
func IterKeyEquals(key string) IterOption
When IterKeyEquals is provided, all yielded triplets have the given key.
By default triplets are not filtered by key.
func IterSetLimit ¶
func IterSetLimit(limit *uint32) IterOption
When IterSetLimit is provided, the given value limits the number of triplets fetched at a time from a server.
By default the limit is set to DefaultBatchSize.
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
type Option ¶
type Option = func(cfg *Config)
func WithClient ¶
WithClient takes an implementation of client that will be used to interact with a database server.
Default client is missed that means a new gRPC client will be created. If this option is provided, options which control gRPC connection are ignored.
func WithConnection ¶
func WithConnection(conn *grpc.ClientConn) Option
WithConnection takes a gRPC connection that will be used to interact with a database server.
If this option is missed, a new connection will be created from the given server address. If this option is provided, WithServerAddress is ignored.
func WithDebugLogger ¶
func WithDebugLogger() Option
WithDebugLogger configures logger to be verbose and human-friendly to simplify the debug.
func WithLogger ¶
WithLogger takes a logger instance will be used to log database operations. You can change the encoding and the log level to customize output.
Default logger prints nothing.
func WithServerAddress ¶
WithServerAddress takes address of the server gRPC API.
The address is ignored if either a client or grpc connection are set by other options.
type Version ¶
type Version struct {
// contains filtered or unexported fields
}
Version represents a unique sequence number of a key-value pair.
The only recommended way to get Version is to fetch data. Inner implementation is hidden from user to provide compatibility of the external interface.