Documentation
¶
Overview ¶
Package zdb implements a client to 0-db: https://github.com/threefoldtech/0-DB
Index ¶
- Constants
- func IsZDBVersion1(ctx context.Context, root string) (bool, error)
- type Client
- type Header
- type Index
- func (p *Index) Delete(name string) error
- func (p *Index) Exists(name string) bool
- func (p *Index) IndexMode(name string) (mode IndexMode, err error)
- func (p *Index) Namespace(name string) (info NSInfo, err error)
- func (p *Index) Namespaces() ([]NSInfo, error)
- func (p *Index) Reserved() (uint64, error)
- type IndexHeader
- type IndexMode
- type NSInfo
- type Namespace
Constants ¶
const (
Prefix = "zdb"
)
Prefix is a string used as prefix in the filesystem volume used to storge 0-db namespaces
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client interface {
Connect() error
Close() error
CreateNamespace(name string) error
Exist(name string) (bool, error)
DeleteNamespace(name string) error
Namespaces() ([]string, error)
Namespace(name string) (Namespace, error)
NamespaceSetSize(name string, size uint64) error
NamespaceSetPassword(name, password string) error
NamespaceSetMode(name, mode string) error
NamespaceSetPublic(name string, public bool) error
NamespaceSetLock(name string, lock bool) error
DBSize() (uint64, error)
}
Client interface
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index represent a part of a disk that is reserved to store 0-db data
func NewIndex ¶
NewIndex creates an Index with root. the root is a directory which has both 'index' and 'data' folders under.
func (*Index) Exists ¶
Exists checks if a namespace exists in the pool or not this method is way faster then using Namespaces cause it doesn't have to read any data
func (*Index) Namespaces ¶
Namespaces returns a list of NSinfo of all the namespace present in the pool
type IndexHeader ¶
type IndexHeader struct {
Magic [4]byte // four bytes magic bytes to recognize the file
Version uint32 // file version, for possible upgrade compatibility
Created uint64 // unix timestamp of creation time
Opened uint64 // unix timestamp of last opened time
Fileid uint16 // current index file id (sync with dataid)
Mode IndexMode // running mode when index was create
}
IndexHeader is the structure contains information about an index adapted from https://github.com/threefoldtech/0-db/blob/development/libzdb/index.h#L31
type IndexMode ¶
type IndexMode uint8
IndexMode represens the mode in which the 0-db is running Adapted from https://github.com/threefoldtech/0-db/blob/development/libzdb/index.h#L4