boltrepo

package
v0.0.0-...-d29814e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2018 License: MIT Imports: 15 Imported by: 0

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

View Source
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

func Enumerate

func Enumerate(db *bolt.DB) (ids []resource.ID, err error)

Enumerate returns the list of team drives contained within db.

Types

type BadCollectionKey

type BadCollectionKey struct {
	Drive  resource.ID
	BadKey []byte
}

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

type BadCommitFileVersion struct {
	Drive  resource.ID
	Commit commit.SeqNum
	BadKey []byte
}

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

type BadCommitKey struct {
	Drive  resource.ID
	BadKey []byte
}

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

type BadCommitStateKey struct {
	Drive  resource.ID
	Commit commit.SeqNum
	BadKey []byte
}

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

type BadDriveVersionKey struct {
	Drive  resource.ID
	BadKey []byte
}

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

type BadDriveViewKey struct {
	Drive  resource.ID
	BadKey []byte
}

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

type BadDriveViewValue struct {
	Drive    resource.ID
	Commit   commit.SeqNum
	BadValue []byte
}

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

type BadFileVersionKey struct {
	File   resource.ID
	BadKey []byte
}

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

type BadFileViewKey struct {
	File   resource.ID
	Drive  resource.ID
	BadKey []byte
}

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

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

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

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

func (ref Commit) Create(data commit.Data) error

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) Data

func (ref Commit) Data() (data commit.Data, err error)

Data returns information about the commit.

func (Commit) Drive

func (ref Commit) Drive() resource.ID

Drive returns the drive ID of the commit.

func (Commit) Exists

func (ref Commit) Exists() (exists bool, err error)

Exists returns true if the commit exists.

func (Commit) Files

func (ref Commit) Files() commit.FileMap

Files returns the map of file changes for the commit.

func (Commit) Path

func (ref Commit) Path() binpath.Text

Path returns the path of the commit.

func (Commit) SeqNum

func (ref Commit) SeqNum() commit.SeqNum

SeqNum returns the sequence number of the commit.

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.

func (Commit) Tree

func (ref Commit) Tree() commit.TreeMap

Tree returns the map of tree changes 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

func (ref CommitStates) Read(start commit.StateNum, p []commit.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 (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.

func (Commits) Next

func (ref Commits) Next() (n commit.SeqNum, err error)

Next returns the sequence number to use for the next commit.

func (Commits) Path

func (ref Commits) Path() binpath.Text

Path returns the path of the commits.

func (Commits) Read

func (ref Commits) Read(start commit.SeqNum, p []commit.Data) (n int, err error)

Read reads commit data for a range of commits 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 (Commits) Ref

func (ref Commits) Ref(c commit.SeqNum) commit.Reference

Ref returns a commit reference.

type Drive

type Drive struct {
	// contains filtered or unexported fields
}

Drive is a drivestream drive reference for a bolt repository.

func (Drive) At

func (ref Drive) At(seqNum commit.SeqNum) (driveversion.Reference, error)

At returns a version reference of the drive at a particular commit.

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) Commit

func (ref Drive) Commit(c commit.SeqNum) commit.Reference

Commit returns a commit reference. Equivalent to Commits().Ref(s).

func (Drive) Commits

func (ref Drive) Commits() commit.Sequence

Commits returns the commit sequence for the drive.

func (Drive) DriveID

func (ref Drive) DriveID() resource.ID

DriveID returns the resource ID of the drive.

func (Drive) Exists

func (ref Drive) Exists() (exists bool, err error)

Exists returns true if the drive exists.

func (Drive) Path

func (ref Drive) Path() binpath.Text

Path returns the path of 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.

func (Drive) View

func (ref Drive) View() driveview.Reference

View returns a view of 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

func (ref DriveVersions) Read(start resource.Version, p []resource.DriveData) (n int, err error)

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

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) Add

func (ref DriveView) Add(seqNum commit.SeqNum, version resource.Version) error

Add adds version as a view of the drive at the commit sequence number.

func (DriveView) At

func (ref DriveView) At(seqNum commit.SeqNum) (r driveversion.Reference, err error)

At returns the version reference of the drive at a particular commit.

TODO: Consider returning the closest commit number as well as the version.

func (DriveView) Drive

func (ref DriveView) Drive() resource.ID

Drive returns the ID of the drive being viewed.

func (DriveView) Path

func (ref DriveView) Path() binpath.Text

Path returns the path of the drive view.

type Drives

type Drives struct {
	// contains filtered or unexported fields
}

Drives accesses a map of drives in a bolt repository.

func (Drives) List

func (ref Drives) List() (ids []resource.ID, err error)

List returns the list of drives contained within the repository.

func (Drives) Path

func (ref Drives) Path() binpath.Text

Path returns the path of the drives.

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) Exists

func (ref File) Exists() (exists bool, err error)

Exists returns true if the file exists.

func (File) FileID

func (ref File) FileID() resource.ID

FileID returns the resource ID of the file.

func (File) Path

func (ref File) Path() binpath.Text

Path returns the path of the file.

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.

func (File) View

func (ref File) View(driveID resource.ID) fileview.Reference

View returns a view of the file for a particular drive.

func (File) Views

func (ref File) Views() fileview.Map

Views returns the view 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

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) Add

func (ref FileView) Add(seqNum commit.SeqNum, version resource.Version) error

Add adds version as a view of the file at the commit sequence number.

func (FileView) At

func (ref FileView) At(seqNum commit.SeqNum) (r fileversion.Reference, err error)

At returns the version reference of the file at a particular commit.

TODO: Consider returning the closest commit number as well as the version.

func (FileView) Drive

func (ref FileView) Drive() resource.ID

Drive returns the ID of the drive being viewed.

func (FileView) File

func (ref FileView) File() resource.ID

File returns the ID of the file.

func (FileView) Path

func (ref FileView) Path() binpath.Text

Path returns the path of the file view.

type FileViews

type FileViews struct {
	// contains filtered or unexported fields
}

FileViews accesses a map of file views in a bolt repository.

func (FileViews) List

func (ref FileViews) List() (drives []resource.ID, err error)

List returns a list of drives with a view of the file.

func (FileViews) Path

func (ref FileViews) Path() binpath.Text

Path returns the path of the file views.

func (FileViews) Ref

func (ref FileViews) Ref(driveID resource.ID) fileview.Reference

Ref returns a view of the file for a particular drive.

type Files

type Files struct {
	// contains filtered or unexported fields
}

Files accesses a map of files in a bolt repository.

func (Files) AddVersions

func (ref Files) AddVersions(fileVersions ...resource.File) error

AddVersions adds file versions to the file map in bulk.

func (Files) AddViewData

func (ref Files) AddViewData(entries ...fileview.Data) error

AddViewData adds view data to the file map in bulk.

func (Files) List

func (ref Files) List() (ids []resource.ID, err error)

List returns the list of files contained within the repository.

func (Files) Path

func (ref Files) Path() binpath.Text

Path returns the path of the files.

func (Files) Ref

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.

func (Page) Create

func (ref Page) Create(data page.Data) error

Create creates the page with the given data.

func (Page) Data

func (ref Page) Data() (data page.Data, err error)

Data returns the page data.

func (Page) Path

func (ref Page) Path() binpath.Text

Path returns the path of the page.

func (Page) SeqNum

func (ref Page) SeqNum() page.SeqNum

SeqNum returns the sequence number of the page.

type Pages

type Pages struct {
	// contains filtered or unexported fields
}

Pages accesses a sequence of pages in a bolt repository.

func (Pages) Clear

func (ref Pages) Clear() error

Clear removes all pages affiliated with a collection.

func (Pages) Next

func (ref Pages) Next() (n page.SeqNum, err error)

Next returns the sequence number to use for the next page of the collection.

func (Pages) Path

func (ref Pages) Path() binpath.Text

Path returns the path of the pages.

func (Pages) Read

func (ref Pages) Read(start page.SeqNum, p []page.Data) (n int, err error)

Read reads the requested pages from a collection.

func (Pages) Ref

func (ref Pages) Ref(seqNum page.SeqNum) page.Reference

Ref returns a page reference for the sequence number.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL