Documentation ¶
Index ¶
- Variables
- type Client
- func (c *Client) Close() error
- func (c *Client) DeleteMetadata(key []byte) error
- func (c *Client) GetMetadata(key []byte) (*metatypes.Metadata, error)
- func (c *Client) ListKeys(cb dbp.ListCallback) error
- func (c *Client) SetMetadata(md metatypes.Metadata) error
- func (c *Client) UpdateMetadata(key []byte, cb UpdateMetadataFunc) (*metatypes.Metadata, error)
- type Config
- type ProcessorConstructor
- type UpdateMetadataFunc
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is the error returned by a metastor client, // in case metadata requested couldn't be found. ErrNotFound = dbp.ErrNotFound // ErrNilKey is the error returned by a metastor client, // in case a nil key is given as part of a request. ErrNilKey = errors.New("nil key given") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client defines the client API of a metadata server. It is used to set, get and delete metadata. It is also used as an optional part of the the main 0-stor client, in order to fetch the metadata automatically for a given key.
A Client is thread-safe.
func NewClient ¶
NewClient creates new client from the given DB. If privKey is not empty, it uses default encryption with the given encryptKey as private key
func NewClientFromConfig ¶
NewClientFromConfig creates a new metastor client from the given config
func (*Client) DeleteMetadata ¶
DeleteMetadata deletes the metadata linked to the given key. It is not considered an error if the metadata was already deleted.
If an error is returned it should be assumed that the data couldn't be deleted and might still exist.
func (*Client) GetMetadata ¶
GetMetadata returns the metadata linked to the given key.
An error is returned in case the linked data couldn't be found. ErrNotFound is returned in case the key couldn't be found. The returned data will always be non-nil in case no error was returned.
func (*Client) ListKeys ¶
func (c *Client) ListKeys(cb dbp.ListCallback) error
ListKeys list all keys in the namespace, and exectute the given callback against each keys. Keys are sorted in lexicographically order
func (*Client) SetMetadata ¶
SetMetadata sets the metadata, using the key defined as part of the given metadata.
An error is returned in case the metadata couldn't be set.
func (*Client) UpdateMetadata ¶
UpdateMetadata updates already existing metadata, returning an error in case there is no metadata to be found for the given key. See `UpdateMetadataFunc` for more information about the required callback.
UpdateMetadata panics when no callback is given.
type Config ¶
type Config struct { // Database is required, // and is used to define te actual KV storage logic, // of the metadata in binary form. // // A client cannot be constructed if no database is given. Database dbp.DB // MarshalFuncPair is optional, // and is used to define custom marshal/unmarshal logic, // which transforms a Metadata struct to binary form and visa versa. // The (gogo) Proto(buf) marshal/unmarshal logic is used if no pair is given. // // A pair always have to given complete, // and a panic will be triggered if a partial one is given. MarshalFuncPair *encoding.MarshalFuncPair // ProcessorConstructor is optional, // and is used to pre- and postprocess the binary data, // prior to storage and just after fetching it. // // No pre- and postprocessing is applied, // in case no constructor is given. ProcessorConstructor ProcessorConstructor }
Config is used to create a (metastor) Client.
type ProcessorConstructor ¶
type ProcessorConstructor func() (processing.Processor, error)
ProcessorConstructor is a constructor type which is used to create a unique Processor for each goroutine where the Processor is needed within a pipeline. This is required as a Processor is not thread-safe.
type UpdateMetadataFunc ¶
UpdateMetadataFunc defines a function which receives an already stored metadata, and which can modify the metadate, safely, prior to returning it. In worst case it can return an error, and that error will be propagated back to the user.