Documentation ¶
Overview ¶
Package boltrepo provides a drivestream repository implementation that is backed by a bolt database.
Sequence numbers within the database are stored as 8 byte big-endian keys.
Index ¶
- Constants
- func Enumerate(db *bolt.DB) (ids []resource.ID, err error)
- type BadCollectionKey
- type BadCollectionStateKey
- type BadCommitFileVersion
- type BadCommitKey
- type BadCommitStateKey
- type BadDriveVersionKey
- type BadDriveViewKey
- type BadDriveViewValue
- type BadFileVersionKey
- type BadFileViewKey
- type BadFileViewValue
- type BadPageKey
- type Collection
- func (ref Collection) Create(data collection.Data) error
- func (ref Collection) Data() (data collection.Data, err error)
- func (ref Collection) Drive() resource.ID
- func (ref Collection) Exists() (exists bool, err error)
- func (ref Collection) Page(pageNum page.SeqNum) page.Reference
- func (ref Collection) Pages() page.Sequence
- func (ref Collection) Path() binpath.Text
- func (ref Collection) SeqNum() collection.SeqNum
- func (ref Collection) State(stateNum collection.StateNum) collection.StateReference
- func (ref Collection) States() collection.StateSequence
- type CollectionState
- type CollectionStates
- func (ref CollectionStates) Next() (n collection.StateNum, err error)
- func (ref CollectionStates) Path() binpath.Text
- func (ref CollectionStates) Read(start collection.StateNum, p []collection.State) (n int, err error)
- func (ref CollectionStates) Ref(stateNum collection.StateNum) collection.StateReference
- type Collections
- type Commit
- func (ref Commit) Create(data commit.Data) error
- func (ref Commit) Data() (data commit.Data, err error)
- func (ref Commit) Drive() resource.ID
- func (ref Commit) Exists() (exists bool, err error)
- func (ref Commit) Files() commit.FileMap
- func (ref Commit) Path() binpath.Text
- func (ref Commit) SeqNum() commit.SeqNum
- func (ref Commit) State(stateNum commit.StateNum) commit.StateReference
- func (ref Commit) States() commit.StateSequence
- func (ref Commit) Tree() commit.TreeMap
- type CommitFiles
- type CommitState
- type CommitStates
- type CommitTree
- type CommitTreeGroup
- type Commits
- type Drive
- func (ref Drive) At(seqNum commit.SeqNum) (driveversion.Reference, error)
- func (ref Drive) Collection(c collection.SeqNum) collection.Reference
- func (ref Drive) Collections() collection.Sequence
- func (ref Drive) Commit(c commit.SeqNum) commit.Reference
- func (ref Drive) Commits() commit.Sequence
- func (ref Drive) DriveID() resource.ID
- func (ref Drive) Exists() (exists bool, err error)
- func (ref Drive) Path() binpath.Text
- func (ref Drive) Stats() (stats drivestream.DriveStats, err error)
- func (ref Drive) Version(v resource.Version) driveversion.Reference
- func (ref Drive) Versions() driveversion.Sequence
- func (ref Drive) View() driveview.Reference
- type DriveVersion
- type DriveVersions
- type DriveView
- type Drives
- type File
- func (ref File) Exists() (exists bool, err error)
- func (ref File) FileID() resource.ID
- func (ref File) Path() binpath.Text
- func (ref File) Version(v resource.Version) fileversion.Reference
- func (ref File) Versions() fileversion.Map
- func (ref File) View(driveID resource.ID) fileview.Reference
- func (ref File) Views() fileview.Map
- type FileVersion
- type FileVersions
- type FileView
- type FileViews
- type Files
- type Page
- type Pages
- type Repository
Constants ¶
const ( RootBucket = "drivestream" SchemaKey = "schema" DriveBucket = "drive" FileBucket = "file" TreeBucket = "tree" CollectionBucket = "collection" DataKey = "data" StateBucket = "state" PageBucket = "page" CommitBucket = "commit" TimeBucket = "time" VersionBucket = "version" ViewBucket = "view" HashBucket = "hash" )
Bucket name constants.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BadCollectionKey ¶
BadCollectionKey reports that the repository contains invalid key data within its collection table.
func (BadCollectionKey) Error ¶
func (e BadCollectionKey) Error() string
Error returns a string representation of the error.
type BadCollectionStateKey ¶
type BadCollectionStateKey struct { Drive resource.ID Collection collection.SeqNum BadKey []byte }
BadCollectionStateKey reports that a collection contains contains an invalid state key.
func (BadCollectionStateKey) Error ¶
func (e BadCollectionStateKey) Error() string
Error returns a string representation of the error.
type BadCommitFileVersion ¶
BadCommitFileVersion reports that a commit contains an invalid file version key.
func (BadCommitFileVersion) Error ¶
func (e BadCommitFileVersion) Error() string
Error returns a string representation of the error.
type BadCommitKey ¶
BadCommitKey reports that the repository contains invalid key data within its commit table.
func (BadCommitKey) Error ¶
func (e BadCommitKey) Error() string
Error returns a string representation of the error.
type BadCommitStateKey ¶
BadCommitStateKey reports that a commit contains contains an invalid state key.
func (BadCommitStateKey) Error ¶
func (e BadCommitStateKey) Error() string
Error returns a string representation of the error.
type BadDriveVersionKey ¶
BadDriveVersionKey reports that the repository contains invalid key data within its drive version table.
func (BadDriveVersionKey) Error ¶
func (e BadDriveVersionKey) Error() string
Error returns a string representation of the error.
type BadDriveViewKey ¶
BadDriveViewKey reports that the repository contains invalid key data within its drive view table.
func (BadDriveViewKey) Error ¶
func (e BadDriveViewKey) Error() string
Error returns a string representation of the error.
type BadDriveViewValue ¶
BadDriveViewValue reports that the repository contains invalid value data within its drive view table.
func (BadDriveViewValue) Error ¶
func (e BadDriveViewValue) Error() string
Error returns a string representation of the error.
type BadFileVersionKey ¶
BadFileVersionKey reports that the repository contains invalid key data within its file version table.
func (BadFileVersionKey) Error ¶
func (e BadFileVersionKey) Error() string
Error returns a string representation of the error.
type BadFileViewKey ¶
BadFileViewKey reports that the repository contains invalid key data within its file view table.
func (BadFileViewKey) Error ¶
func (e BadFileViewKey) Error() string
Error returns a string representation of the error.
type BadFileViewValue ¶
type BadFileViewValue struct { File resource.ID Drive resource.ID Commit commit.SeqNum BadValue []byte }
BadFileViewValue reports that the repository contains invalid value data within its file view table.
func (BadFileViewValue) Error ¶
func (e BadFileViewValue) Error() string
Error returns a string representation of the error.
type BadPageKey ¶
type BadPageKey struct { Drive resource.ID Collection collection.SeqNum BadKey []byte }
BadPageKey reports that a collection contains an invalid page key.
func (BadPageKey) Error ¶
func (e BadPageKey) Error() string
Error returns a string representation of the error.
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection is a drivestream collection reference for a bolt repository.
func (Collection) Create ¶
func (ref Collection) Create(data collection.Data) error
Create creates a new collection with the given sequence number and data. If a collection already exists with the sequence number an error will be returned.
func (Collection) Data ¶
func (ref Collection) Data() (data collection.Data, err error)
Data returns information about the collection.
func (Collection) Drive ¶
func (ref Collection) Drive() resource.ID
Drive returns the drive ID of the collection.
func (Collection) Exists ¶
func (ref Collection) Exists() (exists bool, err error)
Exists returns true if the collection exists.
func (Collection) Page ¶
func (ref Collection) Page(pageNum page.SeqNum) page.Reference
Page returns a page reference.
func (Collection) Pages ¶
func (ref Collection) Pages() page.Sequence
Pages returns the page sequence for the collection.
func (Collection) Path ¶
func (ref Collection) Path() binpath.Text
Path returns the path of the collection.
func (Collection) SeqNum ¶
func (ref Collection) SeqNum() collection.SeqNum
SeqNum returns the sequence number of the collection.
func (Collection) State ¶
func (ref Collection) State(stateNum collection.StateNum) collection.StateReference
State returns a state reference.
func (Collection) States ¶
func (ref Collection) States() collection.StateSequence
States returns the state sequence for the collection.
type CollectionState ¶
type CollectionState struct {
// contains filtered or unexported fields
}
CollectionState is a drivestream collection state accessor for a bolt repository.
func (CollectionState) Create ¶
func (ref CollectionState) Create(data collection.State) error
Create creates the collection state with the given data. If a state already exists with the state's sequence number an error will be returned.
func (CollectionState) Data ¶
func (ref CollectionState) Data() (data collection.State, err error)
Data returns the collection state data.
func (CollectionState) Path ¶
func (ref CollectionState) Path() binpath.Text
Path returns the path of the collection state.
func (CollectionState) StateNum ¶
func (ref CollectionState) StateNum() collection.StateNum
StateNum returns the sequence number of the reference.
type CollectionStates ¶
type CollectionStates struct {
// contains filtered or unexported fields
}
CollectionStates accesses a sequence of collection states in a bolt repository.
func (CollectionStates) Next ¶
func (ref CollectionStates) Next() (n collection.StateNum, err error)
Next returns the state number to use for the next state.
func (CollectionStates) Path ¶
func (ref CollectionStates) Path() binpath.Text
Path returns the path of the collection states.
func (CollectionStates) Read ¶
func (ref CollectionStates) Read(start collection.StateNum, p []collection.State) (n int, err error)
Read reads a subset of states from the sequence, starting at start. Up to len(p) states will be returned in p. The number of states returned is provided as n.
func (CollectionStates) Ref ¶
func (ref CollectionStates) Ref(stateNum collection.StateNum) collection.StateReference
Ref returns a collection state reference for the sequence number.
type Collections ¶
type Collections struct {
// contains filtered or unexported fields
}
Collections accesses a sequence of collections in a bolt repository.
func (Collections) Next ¶
func (ref Collections) Next() (n collection.SeqNum, err error)
Next returns the sequence number to use for the next collection.
func (Collections) Path ¶
func (ref Collections) Path() binpath.Text
Path returns the path of the collections.
func (Collections) Read ¶
func (ref Collections) Read(start collection.SeqNum, p []collection.Data) (n int, err error)
Read reads collection data for a range of collections starting at the given sequence number. Up to len(p) entries will be returned in p. The number of entries is returned as n.
func (Collections) Ref ¶
func (ref Collections) Ref(c collection.SeqNum) collection.Reference
Ref returns a collection reference.
type Commit ¶
type Commit struct {
// contains filtered or unexported fields
}
Commit is a drivestream commit reference for a bolt repository.
func (Commit) Create ¶
Create creates a new commit with the given sequence number and data. If a commit already exists with the sequence number an error will be returned.
func (Commit) State ¶
func (ref Commit) State(stateNum commit.StateNum) commit.StateReference
State returns a state reference.
func (Commit) States ¶
func (ref Commit) States() commit.StateSequence
States returns the state sequence for the commit.
type CommitFiles ¶
type CommitFiles struct {
// contains filtered or unexported fields
}
CommitFiles is a reference to a commit file map.
func (CommitFiles) Add ¶
func (ref CommitFiles) Add(changes ...commit.FileChange) error
Add adds the given file changes to the map. If two or more changes conflict, the last change added takes precedence.
func (CommitFiles) Read ¶
func (ref CommitFiles) Read() (changes []commit.FileChange, err error)
Read returns the set of file changes for the commit, in unspecified order.
type CommitState ¶
type CommitState struct {
// contains filtered or unexported fields
}
CommitState is a reference to a commit state.
func (CommitState) Create ¶
func (ref CommitState) Create(data commit.State) error
Create creates the commit state with the given data. If a state already exists with the state number an error will be returned.
func (CommitState) Data ¶
func (ref CommitState) Data() (data commit.State, err error)
Data returns the commit state data.
func (CommitState) Path ¶
func (ref CommitState) Path() binpath.Text
Path returns the path of the commit state.
func (CommitState) StateNum ¶
func (ref CommitState) StateNum() commit.StateNum
StateNum returns the state number of the reference.
type CommitStates ¶
type CommitStates struct {
// contains filtered or unexported fields
}
CommitStates accesses a sequence of commit states in a bolt repository.
func (CommitStates) Next ¶
func (ref CommitStates) Next() (n commit.StateNum, err error)
Next returns the state number to use for the next state.
func (CommitStates) Path ¶
func (ref CommitStates) Path() binpath.Text
Path returns the path of the commit states.
func (CommitStates) Read ¶
Read reads a subset of states from the sequence, starting at start. Up to len(p) states will be returned in p. The number of states returned is provided as n.
func (CommitStates) Ref ¶
func (ref CommitStates) Ref(stateNum commit.StateNum) commit.StateReference
Ref returns a commit state reference for the sequence number.
type CommitTree ¶
type CommitTree struct {
// contains filtered or unexported fields
}
CommitTree is a reference to a commit file map.
func (CommitTree) Add ¶
func (ref CommitTree) Add(changes ...commit.TreeChange) error
Add adds the given tree changes to the map, grouped by parent. If two or more changes conflict, the last change added takes precedence.
func (CommitTree) Group ¶
func (ref CommitTree) Group(parent resource.ID) commit.TreeGroup
Group returns a reference to a group of changes sharing parent.
func (CommitTree) Parents ¶
func (ref CommitTree) Parents() (parents []resource.ID, err error)
Parents returns a list of parent IDs contained within the map.
func (CommitTree) Path ¶
func (ref CommitTree) Path() binpath.Text
Path returns the path of the commit tree.
type CommitTreeGroup ¶
type CommitTreeGroup struct {
// contains filtered or unexported fields
}
CommitTreeGroup is an unordered group of tree changes sharing a common parent.
func (CommitTreeGroup) Changes ¶
func (ref CommitTreeGroup) Changes() (changes []commit.TreeChange, err error)
Changes returns the set of changes contained in the group.
func (CommitTreeGroup) Parent ¶
func (ref CommitTreeGroup) Parent() resource.ID
Parent returns the parent resource ID of the group.
type Commits ¶
type Commits struct {
// contains filtered or unexported fields
}
Commits accesses a sequence of commits in a bolt repository.
type Drive ¶
type Drive struct {
// contains filtered or unexported fields
}
Drive is a drivestream drive reference for a bolt repository.
func (Drive) Collection ¶
func (ref Drive) Collection(c collection.SeqNum) collection.Reference
Collection returns a collection reference. Equivalent to Collections().Ref(s).
func (Drive) Collections ¶
func (ref Drive) Collections() collection.Sequence
Collections returns the collection sequence for the drive.
func (Drive) Stats ¶
func (ref Drive) Stats() (stats drivestream.DriveStats, err error)
Stats returns statistics about the drive.
func (Drive) Version ¶
func (ref Drive) Version(v resource.Version) driveversion.Reference
Version returns a drive version reference. Equivalent to Versions().Ref(s).
func (Drive) Versions ¶
func (ref Drive) Versions() driveversion.Sequence
Versions returns the version sequence for the drive.
type DriveVersion ¶
type DriveVersion struct {
// contains filtered or unexported fields
}
DriveVersion is a drivestream drive version reference for a bolt repository.
func (DriveVersion) Create ¶
func (ref DriveVersion) Create(data resource.DriveData) error
Create creates a new drive version with the given version number and data. If a version already exists with the version number an error will be returned.
func (DriveVersion) Data ¶
func (ref DriveVersion) Data() (data resource.DriveData, err error)
Data returns the data of the drive version.
func (DriveVersion) Drive ¶
func (ref DriveVersion) Drive() resource.ID
Drive returns the ID of the drive.
func (DriveVersion) Path ¶
func (ref DriveVersion) Path() binpath.Text
Path returns the path of the drive version.
func (DriveVersion) Version ¶
func (ref DriveVersion) Version() resource.Version
Version returns the version number of the drive.
type DriveVersions ¶
type DriveVersions struct {
// contains filtered or unexported fields
}
DriveVersions accesses a sequence of drive versions in a bolt repository.
func (DriveVersions) Next ¶
func (ref DriveVersions) Next() (n resource.Version, err error)
Next returns the next version number in the sequence.
func (DriveVersions) Path ¶
func (ref DriveVersions) Path() binpath.Text
Path returns the path of the drive versions.
func (DriveVersions) Read ¶
Read reads drive data for a range of drive versions starting at the given version number. Up to len(p) entries will be returned in p. The number of entries is returned as n.
func (DriveVersions) Ref ¶
func (ref DriveVersions) Ref(v resource.Version) driveversion.Reference
Ref returns a drive version reference for the version number.
type DriveView ¶
type DriveView struct {
// contains filtered or unexported fields
}
DriveView is a drivestream drive version reference for a bolt repository.
func (DriveView) At ¶
At returns the version reference of the drive at a particular commit.
TODO: Consider returning the closest commit number as well as the version.
type Drives ¶
type Drives struct {
// contains filtered or unexported fields
}
Drives accesses a map of drives in a bolt repository.
func (Drives) Ref ¶
func (ref Drives) Ref(driveID resource.ID) drivestream.DriveReference
Ref returns a drive reference.
type File ¶
type File struct {
// contains filtered or unexported fields
}
File is a drivestream file reference for a bolt repository.
func (File) Version ¶
func (ref File) Version(v resource.Version) fileversion.Reference
Version returns a file version reference. Equivalent to Versions().Ref(s).
func (File) Versions ¶
func (ref File) Versions() fileversion.Map
Versions returns the version map for the file.
type FileVersion ¶
type FileVersion struct {
// contains filtered or unexported fields
}
FileVersion is a drivestream file version reference for a bolt repository.
func (FileVersion) Create ¶
func (ref FileVersion) Create(data resource.FileData) error
Create creates a new file version with the given version number and data. If a version already exists with the version number an error will be returned.
func (FileVersion) Data ¶
func (ref FileVersion) Data() (data resource.FileData, err error)
Data returns the data of the file version.
func (FileVersion) File ¶
func (ref FileVersion) File() resource.ID
File returns the ID of the file.
func (FileVersion) Path ¶
func (ref FileVersion) Path() binpath.Text
Path returns the path of the file version.
func (FileVersion) Version ¶
func (ref FileVersion) Version() resource.Version
Version returns the version number of the file.
type FileVersions ¶
type FileVersions struct {
// contains filtered or unexported fields
}
FileVersions accesses a map of file versions in a bolt repository.
func (FileVersions) List ¶
func (ref FileVersions) List() (v []resource.Version, err error)
List returns a list of version numbers for the file.
func (FileVersions) Path ¶
func (ref FileVersions) Path() binpath.Text
Path returns the path of the file versions.
func (FileVersions) Ref ¶
func (ref FileVersions) Ref(v resource.Version) fileversion.Reference
Ref returns a file version reference for the version number.
type FileView ¶
type FileView struct {
// contains filtered or unexported fields
}
FileView is a drivestream file version reference for a bolt repository.
func (FileView) At ¶
At returns the version reference of the file at a particular commit.
TODO: Consider returning the closest commit number as well as the version.
type FileViews ¶
type FileViews struct {
// contains filtered or unexported fields
}
FileViews accesses a map of file views in a bolt repository.
type Files ¶
type Files struct {
// contains filtered or unexported fields
}
Files accesses a map of files in a bolt repository.
func (Files) AddVersions ¶
AddVersions adds file versions to the file map in bulk.
func (Files) AddViewData ¶
AddViewData adds view data to the file map in bulk.
func (Files) Ref ¶
func (ref Files) Ref(id resource.ID) drivestream.FileReference
Ref returns a file reference.
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
Page is a drivestream page reference for a bolt repository.
type Pages ¶
type Pages struct {
// contains filtered or unexported fields
}
Pages accesses a sequence of pages in a bolt repository.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository is a drive stream repository backed by a bolt database. It should be created by calling New.
func New ¶
func New(db *bolt.DB) Repository
New returns a new drivestream bolt database for the team drive.
func (Repository) Drive ¶
func (repo Repository) Drive(driveID resource.ID) drivestream.DriveReference
Drive returns a drive reference.
func (Repository) Drives ¶
func (repo Repository) Drives() drivestream.DriveMap
Drives returns a drive map.
func (Repository) File ¶
func (repo Repository) File(fileID resource.ID) drivestream.FileReference
File returns a file reference.
func (Repository) Files ¶
func (repo Repository) Files() drivestream.FileMap
Files returns a file map.
func (Repository) Type ¶
func (repo Repository) Type() string
Type returns a string describing the type of the repository.
Source Files ¶
- binary.go
- buckets.go
- collection.go
- collections.go
- collectionstate.go
- collectionstates.go
- commit.go
- commitfiles.go
- commits.go
- commitstate.go
- commitstates.go
- committree.go
- committreegroup.go
- doc.go
- drive.go
- drives.go
- driveversion.go
- driveversions.go
- driveview.go
- enumerate.go
- errors.go
- file.go
- files.go
- fileversion.go
- fileversions.go
- fileview.go
- fileviews.go
- page.go
- pages.go
- repository.go
- schema.go