Documentation
¶
Index ¶
- Variables
- func EpochNow() int64
- type Client
- func (c *Client) Check(meta metatypes.Metadata, fast bool) (storage.CheckStatus, error)
- func (c *Client) Close() error
- func (c *Client) Delete(meta metatypes.Metadata) error
- func (c *Client) Read(meta metatypes.Metadata, w io.Writer) error
- func (c *Client) ReadRange(meta metatypes.Metadata, w io.Writer, offset, length int64) error
- func (c *Client) Repair(md metatypes.Metadata) (*metatypes.Metadata, error)
- func (c *Client) Traverse(startKey []byte, fromEpoch, toEpoch int64) (TraverseIterator, error)
- func (c *Client) TraversePostOrder(startKey []byte, fromEpoch, toEpoch int64) (TraverseIterator, error)
- func (c *Client) Write(key []byte, r io.Reader) (*metatypes.Metadata, error)
- func (c *Client) WriteLinked(key, prevKey []byte, r io.Reader) (meta, prevMeta *metatypes.Metadata, err error)
- func (c *Client) WriteWithUserMeta(key []byte, r io.Reader, userDefined map[string]string) (*metatypes.Metadata, error)
- type Config
- type DataStorConfig
- type DataStorTLSConfig
- type TLSVersion
- type TraverseIterator
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNilKey is an error returned in case a nil key is given to a client method. ErrNilKey = errors.New("Client: nil/empty key given") // ErrNilContext is an error returned in case a context given to a client method is nil. ErrNilContext = errors.New("Client: nil context given") // ErrRepairSupport is returned when data is not stored using replication or distribution ErrRepairSupport = errors.New("data is not stored using replication or distribution, repair impossible") // ErrInvalidReadRange is returned when given read range is not valid ErrInvalidReadRange = errors.New("invalid read range") )
var ( // ErrInvalidTraverseIterator is an error returned when (meta)data // of an iterator is requested, while that iterator is in an invalid state. ErrInvalidTraverseIterator = errors.New( "TraverseIterator is invalid: did you call (TraverseIterator).Next?") // ErrInvalidEpochRange is an error returned when, // during the creation of a traverse iterator, // the given epoch range is invalid (e.g. start > end). ErrInvalidEpochRange = errors.New( "cannot create traverse iterator: epoch range is invalid") )
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client defines 0-stor client
func NewClient ¶
NewClient creates a 0-stor client, with the data (zstordb) cluster already created, used to read/write object data, as well as the metastor client, which is used to read/write the metadata of the objects. if metaClient is not nil, the metadata will be written at Write operation using the given metaClient.
func NewClientFromConfig ¶
func NewClientFromConfig(cfg Config, metastorClient *metastor.Client, jobCount int) (*Client, error)
NewClientFromConfig creates new 0-stor client using the given config.
If JobCount is 0 or negative, the default JobCount will be used, as defined by the pipeline package.
func (*Client) Check ¶
Check gets the status of data stored in a 0-stor cluster. It does so using the chunks stored as metadata CheckStatusInvalid indicates the data is invalid and non-repairable, Any other value indicates the data is readable, but if it's not optimal, it could use a repair.
func (*Client) Delete ¶
Delete deletes the data, from the 0-stor cluster, using the reference information fetched from the given metadata (which is linked to the given key).
func (*Client) Read ¶
Read reads the data, from the 0-stor cluster, using the reference information fetched from the given metadata.
func (*Client) Repair ¶
Repair repairs broken data, whether it's needed or not.
If the data is distributed and the amount of corrupted chunks is acceptable, we recreate the missing chunks.
Id the data is replicated and we still have one valid replication, we create the missing replications until we reach the replication number configured in the config.
if the data has not been distributed or replicated, we can't repair it, or if not enough shards are available we cannot repair it either.
func (*Client) Traverse ¶
func (c *Client) Traverse(startKey []byte, fromEpoch, toEpoch int64) (TraverseIterator, error)
Traverse traverses the stored (meta)data, which is chained together using the (*Client).WriteLinked method. It starts searching from a given startKey and will iterate through all (meta)data, which has a registered CreationEpoch in the given inclusive epoch range.
Both the fromEpoch and toEpoch input parameters are optional and do not have to be given. Any value of 0 or less can be given as to not specify them. Not giving an epoch limit, simply means that this limit won't be used/enforced.
An error will be returned in case no (valid) startKey is given, or in case the given epoch range is invalid (fromEpoch > toEpoch).
The returned TraverseIterator is only valid, as long as the client which created and owns that iterator is valid (e.g. not closed). This traverse iterator is NOT /THREAD-SAFE/.
This method is to be considered EXPERIMENTAL, and might be moved or changed in a future milestone. See https://github.com/zero-os/0-stor/issues/424 for more information.
func (*Client) TraversePostOrder ¶
func (c *Client) TraversePostOrder(startKey []byte, fromEpoch, toEpoch int64) (TraverseIterator, error)
TraversePostOrder traverses the stored (meta)data, backwards, which is chained together using the (*Client).WriteLinked method. It starts searching from a given startKey and will iterate through all (meta)data, which has a registered CreationEpoch in the given inclusive epoch range.
Both the fromEpoch and toEpoch input parameters are optional and do not have to be given. Any value of 0 or less can be given as to not specify them. Not giving an epoch limit, simply means that this limit won't be used/enforced.
As this method traverses backwards, the startKey is expected to be the newest data as the given fromEpoch should be the most recent time in this chain.
An error will be returned in case no (valid) startKey is given, or in case the given epoch range is invalid (toEpoch > fromEpoch).
The returned TraverseIterator is only valid, as long as the client which created and owns that iterator is valid (e.g. not closed). This traverse iterator is NOT /THREAD-SAFE/.
This method is to be considered EXPERIMENTAL, and might be moved or changed in a future milestone. See https://github.com/zero-os/0-stor/issues/424 for more information.
func (*Client) Write ¶
Write writes the data to a 0-stor cluster, storing the metadata using the internal metastor client.
func (*Client) WriteLinked ¶
func (c *Client) WriteLinked(key, prevKey []byte, r io.Reader) (meta, prevMeta *metatypes.Metadata, err error)
WriteLinked writes the data to a 0-stor cluster, storing the metadata using the internal metastor client, as well as linking the metadata created for this data, to the metadata linked to the given previous key.
This method is to be considered EXPERIMENTAL, and might be moved or changed in a future milestone. See https://github.com/zero-os/0-stor/issues/424 for more information.
func (*Client) WriteWithUserMeta ¶
func (c *Client) WriteWithUserMeta(key []byte, r io.Reader, userDefined map[string]string) (*metatypes.Metadata, error)
WriteWithUserMeta writes the data to a 0-stor cluster, storing the metadata using the internal metastor client. The given user defined metadata will be stored in the `UserDefined` field of the metadata.
type Config ¶
type Config struct { // Password defines the optional 0-db password. Password string `yaml:"password" json:"password"` // Namespace defines the label (ID of namespace), // to be used for all read/write/delete operations. Namespace string `yaml:"namespace" json:"namespace"` // DataStor defines the configuration for the zstordb data shards (servers), // at least one zstordb shard is given, but more might be required, // if you define a distributed storage configuration in the pipeline config. DataStor DataStorConfig `yaml:"datastor" json:"datastor"` }
Config defines the configuration of the 0-stor client. It configures everything from namespaces, permissions, storage clusters, as well as the entire read/write pipeline, used to read and write data.
func ReadConfig ¶
ReadConfig reads the configuration from a file. NOTE that it isn't validated, this will be done automatically, when you use the config to create a 0-stor client.
type DataStorConfig ¶
type DataStorConfig struct { // Shards defines the Listed shards, at least one listed shard is required Shards []string `yaml:"shards" json:"shards"` // required // Pipeline defines the object read/write pipeline configuration // for this 0-stor client. It defines how to structure, // process, identify and store all data to be written, // and that same configuration is required to read the data back. Pipeline pipeline.Config `yaml:"pipeline" json:"pipeline"` // TLS defines the optional global TLS config, // which is used for all lised and unlisted datastor shards, in case it is given. TLS DataStorTLSConfig `yaml:"tls" json:"tls"` }
DataStorConfig is used to configure a zstordb cluster.
type DataStorTLSConfig ¶
type DataStorTLSConfig struct { // has to be true in order to enable this config Enabled bool `yaml:"enabled" json:"enabled"` // when not given the TLS implemenation will skip certification verification, // exposing the client to man-in-the-middle attacks ServerName string `yaml:"server" json:"server"` // when not given, the system CA will be used RootCA string `yaml:"root_ca" json:"root_ca"` // optional min/max TLS versions, limiting the // accepted TLS version used by the server MinVersion TLSVersion `yaml:"min_version" json:"min_version"` MaxVersion TLSVersion `yaml:"max_version" json:"max_version"` }
DataStorTLSConfig is used to config the global TLS config used for all listed and unlisted datastor shards.
type TLSVersion ¶
type TLSVersion uint8
TLSVersion defines a TLS Version, usable to restrict the possible TLS Versions.
const ( // UndefinedTLSVersion defines an undefined TLS Version, // which can can be used to signal the desired use of a default TLS Version UndefinedTLSVersion TLSVersion = iota // TLSVersion12 defines TLS version 1.2, // and is also the current default TLS Version. TLSVersion12 // TLSVersion11 defines TLS version 1.1 TLSVersion11 // TLSVersion10 defines TLS version 1.0, // but should not be used, unless you have no other option. TLSVersion10 )
func (TLSVersion) MarshalText ¶
func (v TLSVersion) MarshalText() (text []byte, err error)
MarshalText implements encoding.TextMarshaler.MarshalText
func (*TLSVersion) UnmarshalText ¶
func (v *TLSVersion) UnmarshalText(text []byte) error
UnmarshalText implements encoding.TextUnmarshaler.UnmarshalText
func (TLSVersion) VersionTLSOrDefault ¶
func (v TLSVersion) VersionTLSOrDefault(def uint16) uint16
VersionTLSOrDefault returns the tls.VersionTLS value, which corresponds to this TLSVersion. Or it returns the given default TLS Version in case this TLS Version is undefined.
type TraverseIterator ¶
type TraverseIterator interface { // Next moves the iterator one (valid) position forward, // returning false if the iterator has been exhausted. // // Next has to be called before any (meta)data can be fetched or read. Next() bool // PeekNextKey returns the next key in line. // Note that due to the specified epoch range it // might mean that the data of this key will never be available, // in case the creation time of the linked (meta)data is // not within the specified time range. // // False is returned in case the iterator has been exhausted, // and thus no next key is lined up. PeekNextKey() ([]byte, bool) // GetMetadata returns the current (and already fetched) metadata. // // An error is returned in case no metadata is available, // due to the iterator being in an invalid state. GetMetadata() (*metatypes.Metadata, error) // ReadData reads the data available for the current metadata, // and writes it to the specified writer. // // An error is returned in case the iterator is in an invalid state, // and thus no data is available to be read. ReadData(w io.Writer) error }
TraverseIterator defines the interface of an iterator, which is returned by a client traverse function.
Directories
¶
Path | Synopsis |
---|---|
Package datastor defines the clients and other types, to be used to interface with a zstordb server.
|
Package datastor defines the clients and other types, to be used to interface with a zstordb server. |
pipeline
Package pipeline is used to write/read content from/to a datastor cluster.
|
Package pipeline is used to write/read content from/to a datastor cluster. |
pipeline/crypto
Package crypto collects common cryptographic components.
|
Package crypto collects common cryptographic components. |
encoding/proto
Package proto is a generated protocol buffer package.
|
Package proto is a generated protocol buffer package. |