storage

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDuplicateStore = errors.New("store already exists")

ErrDuplicateStore is used when an attempt is made to create a duplicate store.

View Source
var ErrGetAllNotSupported = errors.New("getting all key-value pairs is not supported")

ErrGetAllNotSupported is used when the get all function is not supported by the store implementation.

View Source
var ErrIndexingNotSupported = errors.New("indexing is not supported")

ErrIndexingNotSupported is used when create index is not supported by the store implementation.

View Source
var ErrKeyRequired = errors.New("key is mandatory")

ErrKeyRequired is returned when an attempt is made to call a method with an empty key when it's not allowed.

View Source
var ErrQueryingNotSupported = errors.New("querying is not supported")

ErrQueryingNotSupported is used when querying is not supported by the store implementation.

View Source
var ErrStoreNotFound = errors.New("store not found")

ErrStoreNotFound is used when a given store was not found in a provider.

View Source
var ErrValueNotFound = errors.New("store does not have a value associated with this key")

ErrValueNotFound is used when an attempt is made to retrieve a value using a key that isn't in the store.

Functions

This section is empty.

Types

type CreateIndexRequest added in v0.1.3

type CreateIndexRequest struct {
	// IndexStorageLocation is the place where the index (and any associated configuration data) is stored.
	// The usage of this depends on the implementation.
	IndexStorageLocation string
	// IndexName is the user-defined name that should be assigned to this new index.
	IndexName string
	// WhatToIndex are the field(s) that you want to index.
	// The syntax for this string depends on the implementation.
	WhatToIndex string
}

CreateIndexRequest represents the information that a store needs to create a new user-specified index.

type Provider

type Provider interface {
	// CreateStore creates a new store with the given name.
	CreateStore(name string) error

	// OpenStore opens an existing store and returns it.
	OpenStore(name string) (Store, error)

	// CloseStore closes the store with the given name.
	CloseStore(name string) error

	// Close closes all stores created under this store provider.
	Close() error
}

Provider represents a storage provider.

type ResultsIterator added in v0.1.3

type ResultsIterator interface {
	// Next moves the pointer to the next value in the iterator. It returns false if the iterator is exhausted.
	Next() (bool, error)

	// Release releases associated resources. Release should always result in success
	// and can be called multiple times without causing an error.
	Release() error

	// Key returns the key of the current key-value pair.
	Key() (string, error)

	// Value returns the value of the current key-value pair.
	Value() ([]byte, error)
}

ResultsIterator represents an iterator that can be used to iterate over all the stored key-value pairs.

type Store

type Store interface {
	// Put stores the key-value pair.
	Put(k string, v []byte) error

	// GetAll fetches all the key-value pairs within this store.
	GetAll() (map[string][]byte, error)

	// Get fetches the value associated with the given key.
	Get(k string) ([]byte, error)

	// CreateIndex creates an index in the store based on the provided CreateIndexRequest.
	CreateIndex(createIndexRequest CreateIndexRequest) error

	// Query queries the store for data based on the provided query string, the format of
	// which will be dependent on what the underlying store requires.
	Query(query string) (ResultsIterator, error)

	// Delete deletes the key-value pair associated with k.
	Delete(k string) error
}

Store represents a storage database.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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