Documentation ¶
Overview ¶
Package db contains a database abstraction layer.
Index ¶
Constants ¶
const VolumeIDLen = 64
Variables ¶
var ( ErrPeerNotFound = errors.New("peer not found") ErrNoStorageForPeer = errors.New("no storage offered to peer") ErrNoLocationForPeer = errors.New("no network location known for peer") )
var ( ErrSharingKeyNameInvalid = errors.New("invalid sharing key name") ErrSharingKeyNotFound = errors.New("sharing key not found") ErrSharingKeyExist = errors.New("sharing key exists already") )
var ( ErrVolNameInvalid = errors.New("invalid volume name") ErrVolNameNotFound = errors.New("volume name not found") ErrVolNameExist = errors.New("volume name exists already") ErrVolumeIDNotFound = errors.New("volume ID not found") ErrVolumeStorageExist = errors.New("volume storage name exists already") )
Functions ¶
This section is empty.
Types ¶
type DB ¶
DB provides abstracted access to the Bolt database used by the server.
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
func (*Peer) Locations ¶
func (p *Peer) Locations() *PeerLocations
func (*Peer) Storage ¶
func (p *Peer) Storage() *PeerStorage
type PeerLocations ¶
type PeerLocations struct {
// contains filtered or unexported fields
}
func (*PeerLocations) Get ¶
func (p *PeerLocations) Get() (addr string, err error)
Get an address to try, to connect to the peer.
Returned addr is valid after the transaction.
TODO support multiple addresses to attempt, with some idea of preferring recent ones.
func (*PeerLocations) Set ¶
func (p *PeerLocations) Set(addr string) error
Set the network location where the peer can be contacted.
TODO support multiple addresses to attempt, with some idea of preferring recent ones.
type PeerStorage ¶
type PeerStorage struct {
// contains filtered or unexported fields
}
func (*PeerStorage) Allow ¶
func (p *PeerStorage) Allow(backend string) error
func (*PeerStorage) Open ¶
Open key-value stores as allowed for this peer. Uses the opener function for the actual open action.
If the peer is not allowed to use any storage, returns ErrNoStorageForPeer.
Returned KV is valid after the transaction. Strings passed to the opener function are valid after the transaction.
type Peers ¶
type Peers struct {
// contains filtered or unexported fields
}
type SharingKey ¶
type SharingKey struct {
// contains filtered or unexported fields
}
func (*SharingKey) Name ¶
func (s *SharingKey) Name() string
Name returns the name of the sharing key.
Returned value is valid after the transaction.
func (*SharingKey) Secret ¶
func (s *SharingKey) Secret(out *[32]byte)
Secret copies the secret key to out.
out is valid after the transaction.
type SharingKeys ¶
type SharingKeys struct {
// contains filtered or unexported fields
}
func (*SharingKeys) Add ¶
func (b *SharingKeys) Add(name string, key *[32]byte) (*SharingKey, error)
Add a sharing key.
If name is invalid, returns ErrSharingKeyNameInvalid.
If a sharing key by that name already exists, returns ErrSharingKeyExist.
func (*SharingKeys) Get ¶
func (b *SharingKeys) Get(name string) (*SharingKey, error)
Get a sharing key.
If the sharing key name is not found, returns ErrSharingKeyNotFound.
type Tx ¶
Tx is a database transaction.
Unless otherwise stated, any values returned by methods here (and transitively from their methods) are only valid while the transaction is alive. This does not apply to returned error values.
func (*Tx) SharingKeys ¶
func (tx *Tx) SharingKeys() *SharingKeys
type Volume ¶
type Volume struct {
// contains filtered or unexported fields
}
func (*Volume) InodeBucket ¶
InodeBucket returns a bolt bucket for storing inodes in.
func (*Volume) SnapBucket ¶
SnapBucket returns a bolt bucket for storing snapshots in.
func (*Volume) Storage ¶
func (v *Volume) Storage() *VolumeStorage
type VolumeID ¶
type VolumeID [VolumeIDLen]byte
type VolumeStorage ¶
type VolumeStorage struct {
// contains filtered or unexported fields
}
func (*VolumeStorage) Add ¶
func (vs *VolumeStorage) Add(name string, backend string, sharingKey *SharingKey) error
Add a storage backend to be used by the volume.
Active Volume instances are not notified.
If volume has storage by that name already, returns ErrVolumeStorageExist.
func (*VolumeStorage) Cursor ¶
func (vs *VolumeStorage) Cursor() *VolumeStorageCursor
type VolumeStorageCursor ¶
type VolumeStorageCursor struct {
// contains filtered or unexported fields
}
func (*VolumeStorageCursor) First ¶
func (c *VolumeStorageCursor) First() *VolumeStorageItem
func (*VolumeStorageCursor) Next ¶
func (c *VolumeStorageCursor) Next() *VolumeStorageItem
type VolumeStorageItem ¶
type VolumeStorageItem struct {
// contains filtered or unexported fields
}
func (*VolumeStorageItem) Backend ¶
func (item *VolumeStorageItem) Backend() (string, error)
Backend returns the storage backend for this item.
Returned value is valid after the transaction.
func (*VolumeStorageItem) SharingKeyName ¶
func (item *VolumeStorageItem) SharingKeyName() (string, error)
SharingKeyName returns the sharing key name for this item.
Returned value is valid after the transaction.