Documentation ¶
Overview ¶
Package db contains a database abstraction layer.
Index ¶
- Constants
- Variables
- type ClockNotFoundError
- type DB
- type DirEntry
- type Dirs
- func (b *Dirs) Delete(parentInode uint64, name string) error
- func (b *Dirs) Get(parentInode uint64, name string) (*wirefs.Dirent, error)
- func (b *Dirs) List(inode uint64) *DirsCursor
- func (b *Dirs) Put(parentInode uint64, name string, de *wirefs.Dirent) error
- func (b *Dirs) Rename(parentInode uint64, oldName string, newName string) (*DirEntry, error)
- func (b *Dirs) Tombstone(parentInode uint64, name string) error
- func (b *Dirs) TombstoneCreate(parentInode uint64, name string) error
- type DirsCursor
- type Peer
- type PeerLocations
- type PeerStorage
- type PeerVolumes
- type Peers
- type PeersCursor
- type SharingKey
- type SharingKeys
- type Tx
- type Volume
- func (v *Volume) Clock() *VolumeClock
- func (v *Volume) Conflicts() *VolumeConflicts
- func (v *Volume) Dirs() *Dirs
- func (v *Volume) Epoch() (clock.Epoch, error)
- func (v *Volume) InodeBucket() *bolt.Bucket
- func (v *Volume) NextEpoch() (clock.Epoch, error)
- func (v *Volume) SnapBucket() *bolt.Bucket
- func (v *Volume) Storage() *VolumeStorage
- func (v *Volume) VolumeID(out *VolumeID)
- type VolumeClock
- func (vc *VolumeClock) Create(parentInode uint64, name string, now clock.Epoch) (*clock.Clock, error)
- func (vc *VolumeClock) Get(parentInode uint64, name string) (*clock.Clock, error)
- func (vc *VolumeClock) Put(parentInode uint64, name string, c *clock.Clock) error
- func (vc *VolumeClock) Tombstone(parentInode uint64, name string, now clock.Epoch) error
- func (vc *VolumeClock) Update(parentInode uint64, name string, now clock.Epoch) (c *clock.Clock, changed bool, err error)
- func (vc *VolumeClock) UpdateFromChild(parentInode uint64, name string, child *clock.Clock) (changed bool, err error)
- func (vc *VolumeClock) UpdateOrCreate(parentInode uint64, name string, now clock.Epoch) (c *clock.Clock, changed bool, err error)
- type VolumeConflicts
- func (vc *VolumeConflicts) Add(parentInode uint64, c *clock.Clock, de *wirepeer.Dirent) error
- func (vc *VolumeConflicts) Delete(parentInode uint64, name string, clockBuf []byte) error
- func (vc *VolumeConflicts) Get(parentInode uint64, name string, clockBuf []byte) *VolumeConflictsItem
- func (vc *VolumeConflicts) List(parentInode uint64, name string) *VolumeConflictsCursor
- func (vc *VolumeConflicts) ListAll(parentInode uint64) *VolumeConflictsCursor
- type VolumeConflictsCursor
- type VolumeConflictsItem
- type VolumeID
- type VolumeStorage
- type VolumeStorageCursor
- type VolumeStorageItem
- type Volumes
- func (b *Volumes) Add(name string, volID *VolumeID, storage string, sharingKey *SharingKey) (*Volume, error)
- func (b *Volumes) Create(name string, storage string, sharingKey *SharingKey) (*Volume, error)
- func (b *Volumes) GetByName(name string) (*Volume, error)
- func (b *Volumes) GetByVolumeID(volID *VolumeID) (*Volume, error)
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") ErrVolumeIDExist = errors.New("volume ID exists already") ErrVolumeIDNotFound = errors.New("volume ID not found") ErrVolumeEpochWraparound = errors.New("volume epoch wraparound") )
var (
ErrVolumeStorageExist = errors.New("volume storage name exists already")
)
Functions ¶
This section is empty.
Types ¶
type ClockNotFoundError ¶
func (*ClockNotFoundError) Error ¶
func (e *ClockNotFoundError) Error() string
type DB ¶
DB provides abstracted access to the Bolt database used by the server.
type DirEntry ¶
type DirEntry struct {
// contains filtered or unexported fields
}
type Dirs ¶
type Dirs struct {
// contains filtered or unexported fields
}
func (*Dirs) Delete ¶
Delete the entry in parent directory with the given name.
Returns fuse.ENOENT if an entry does not exist.
func (*Dirs) Get ¶
Get the entry in parent directory with the given name.
Returned value is valid after the transaction.
func (*Dirs) List ¶
func (b *Dirs) List(inode uint64) *DirsCursor
func (*Dirs) Rename ¶
Rename renames an entry in the parent directory from oldName to newName.
Returns the overwritten entry, or nil.
type DirsCursor ¶
type DirsCursor struct {
// contains filtered or unexported fields
}
func (*DirsCursor) First ¶
func (c *DirsCursor) First() *DirEntry
func (*DirsCursor) Next ¶
func (c *DirsCursor) Next() *DirEntry
func (*DirsCursor) Seek ¶
func (c *DirsCursor) Seek(name string) *DirEntry
Seek to first name equal to name, or the next one if exact match is not found.
Passing an empty name seeks to the beginning of the directory.
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
func (*Peer) Volumes ¶
func (p *Peer) Volumes() *PeerVolumes
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 PeerVolumes ¶
type PeerVolumes struct {
// contains filtered or unexported fields
}
func (*PeerVolumes) Allow ¶
func (p *PeerVolumes) Allow(vol *Volume) error
func (*PeerVolumes) IsAllowed ¶
func (p *PeerVolumes) IsAllowed(vol *Volume) bool
type Peers ¶
type Peers struct {
// contains filtered or unexported fields
}
func (*Peers) Cursor ¶
func (b *Peers) Cursor() *PeersCursor
type PeersCursor ¶
type PeersCursor struct {
// contains filtered or unexported fields
}
func (*PeersCursor) First ¶
func (c *PeersCursor) First() *Peer
func (*PeersCursor) Next ¶
func (c *PeersCursor) Next() *Peer
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) Clock ¶
func (v *Volume) Clock() *VolumeClock
func (*Volume) Conflicts ¶
func (v *Volume) Conflicts() *VolumeConflicts
func (*Volume) Epoch ¶
Epoch returns the current mutation epoch of the volume.
Returned value is valid after the transaction.
func (*Volume) InodeBucket ¶
InodeBucket returns a bolt bucket for storing inodes in.
func (*Volume) NextEpoch ¶
NextEpoch increments the epoch and returns the new value. The value is only safe to use if the transaction commits.
If epoch wraps around, returns ErrVolumeEpochWraparound. This should be boil-the-oceans rare.
Returned value is valid after the transaction.
func (*Volume) SnapBucket ¶
SnapBucket returns a bolt bucket for storing snapshots in.
func (*Volume) Storage ¶
func (v *Volume) Storage() *VolumeStorage
type VolumeClock ¶
type VolumeClock struct {
// contains filtered or unexported fields
}
VolumeClock tracks the logical clocks for files and directories stored in the volume.
Logical clocks are kept separate from the directory entries, as they modified at different rates. Specifically, Vector Time Pairs cause modification times to trickle upward in the tree, and keeping the clocks separate allows us to do this as a pure database operation, without coordinating with the active FS Node objects.
func (*VolumeClock) UpdateFromChild ¶
type VolumeConflicts ¶
type VolumeConflicts struct {
// contains filtered or unexported fields
}
VolumeConflicts tracks the alternate versions of directory entries.
func (*VolumeConflicts) Delete ¶
func (vc *VolumeConflicts) Delete(parentInode uint64, name string, clockBuf []byte) error
func (*VolumeConflicts) Get ¶
func (vc *VolumeConflicts) Get(parentInode uint64, name string, clockBuf []byte) *VolumeConflictsItem
func (*VolumeConflicts) List ¶
func (vc *VolumeConflicts) List(parentInode uint64, name string) *VolumeConflictsCursor
func (*VolumeConflicts) ListAll ¶
func (vc *VolumeConflicts) ListAll(parentInode uint64) *VolumeConflictsCursor
ListAll iterates over all of the conflict entries for this directory.
type VolumeConflictsCursor ¶
type VolumeConflictsCursor struct {
// contains filtered or unexported fields
}
func (*VolumeConflictsCursor) Delete ¶
func (c *VolumeConflictsCursor) Delete() error
Delete the current item.
func (*VolumeConflictsCursor) First ¶
func (c *VolumeConflictsCursor) First() *VolumeConflictsItem
func (*VolumeConflictsCursor) Next ¶
func (c *VolumeConflictsCursor) Next() *VolumeConflictsItem
type VolumeConflictsItem ¶
type VolumeConflictsItem struct {
// contains filtered or unexported fields
}
func (*VolumeConflictsItem) Clock ¶
func (item *VolumeConflictsItem) Clock() (*clock.Clock, error)
Clock returns the clock for this item.
Returned value is valid after the transaction.
func (*VolumeConflictsItem) Dirent ¶
func (item *VolumeConflictsItem) Dirent(out *wirepeer.Dirent) error
Dirent returns the directory entry for this item.
out is valid after the transaction.
func (*VolumeConflictsItem) Name ¶
func (item *VolumeConflictsItem) Name() string
Name returns the file name for this item.
This is mostly useful when used with ListAll.
Returned value is valid after the transaction.
type VolumeID ¶
type VolumeID [VolumeIDLen]byte
func (*VolumeID) MarshalBinary ¶
func (*VolumeID) MarshalText ¶
func (*VolumeID) UnmarshalBinary ¶
func (*VolumeID) UnmarshalText ¶
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.
type Volumes ¶
type Volumes struct {
// contains filtered or unexported fields
}
func (*Volumes) Add ¶
func (b *Volumes) Add(name string, volID *VolumeID, storage string, sharingKey *SharingKey) (*Volume, error)
Add adds a volume that was created elsewhere to this node.
If the name exists already, returns ErrVolNameExist.