Documentation ¶
Index ¶
- Constants
- Variables
- func IsCommitType(t *types.Type) bool
- func NewCommit(value types.Value, parents types.Set, meta types.Struct) types.Struct
- func NewRemoteDatabaseServer(cs chunks.ChunkStore, port int) *remoteDatabaseServer
- func Pull(srcDB, sinkDB Database, sourceRef, sinkHeadRef types.Ref, concurrency int, ...)
- type Database
- type Factory
- type Handler
- type LocalDatabase
- func (ds *LocalDatabase) Close() error
- func (lds *LocalDatabase) Commit(datasetID string, commit types.Struct) (Database, error)
- func (ds *LocalDatabase) Datasets() types.Map
- func (lds *LocalDatabase) Delete(datasetID string) (Database, error)
- func (ds *LocalDatabase) Head(datasetID string) types.Struct
- func (ds *LocalDatabase) HeadRef(datasetID string) types.Ref
- func (ds *LocalDatabase) MaybeHead(datasetID string) (types.Struct, bool)
- func (ds *LocalDatabase) MaybeHeadRef(datasetID string) (types.Ref, bool)
- func (ds *LocalDatabase) ReadValue(r hash.Hash) types.Value
- func (ds *LocalDatabase) WriteValue(v types.Value) types.Ref
- type PullProgress
- type RemoteDatabaseClient
- func (ds *RemoteDatabaseClient) Close() error
- func (rds *RemoteDatabaseClient) Commit(datasetID string, commit types.Struct) (Database, error)
- func (ds *RemoteDatabaseClient) Datasets() types.Map
- func (rds *RemoteDatabaseClient) Delete(datasetID string) (Database, error)
- func (ds *RemoteDatabaseClient) Head(datasetID string) types.Struct
- func (ds *RemoteDatabaseClient) HeadRef(datasetID string) types.Ref
- func (ds *RemoteDatabaseClient) MaybeHead(datasetID string) (types.Struct, bool)
- func (ds *RemoteDatabaseClient) MaybeHeadRef(datasetID string) (types.Ref, bool)
- func (ds *RemoteDatabaseClient) ReadValue(r hash.Hash) types.Value
- func (ds *RemoteDatabaseClient) WriteValue(v types.Value) types.Ref
- type RemoteStoreFactory
- type URLParams
Constants ¶
const ( ParentsField = "parents" ValueField = "value" MetaField = "meta" )
const NomsVersionHeader = "x-noms-vers"
NomsVersionHeader is the name of the header that Noms clients and servers must set in every request/response.
Variables ¶
var ( ErrOptimisticLockFailed = errors.New("Optimistic lock failed on database Root update") ErrMergeNeeded = errors.New("Dataset head is not ancestor of commit") )
var ( // HandleWriteValue is meant to handle HTTP POST requests to the writeValue/ server endpoint. The payload should be an appropriately-ordered sequence of Chunks to be validated and stored on the server. // TODO: Nice comment about what headers it expects/honors, payload format, and error responses. HandleWriteValue = versionCheck(handleWriteValue) // HandleGetRefs is meant to handle HTTP POST requests to the getRefs/ server endpoint. Given a sequence of Chunk hashes, the server will fetch and return them. // TODO: Nice comment about what headers it expects/honors, payload format, and responses. HandleGetRefs = versionCheck(handleGetRefs) // HandleWriteValue is meant to handle HTTP POST requests to the hasRefs/ server endpoint. Given a sequence of Chunk hashes, the server check for their presence and return a list of true/false responses. // TODO: Nice comment about what headers it expects/honors, payload format, and responses. HandleHasRefs = versionCheck(handleHasRefs) // HandleRootGet is meant to handle HTTP GET requests to the root/ server endpoint. The server returns the hash of the Root as a string. // TODO: Nice comment about what headers it expects/honors, payload format, and responses. HandleRootGet = versionCheck(handleRootGet) // HandleWriteValue is meant to handle HTTP POST requests to the root/ server endpoint. This is used to update the Root to point to a new Chunk. // TODO: Nice comment about what headers it expects/honors, payload format, and error responses. HandleRootPost = versionCheck(handleRootPost) )
Functions ¶
func IsCommitType ¶
func NewCommit ¶
NewCommit creates a new commit object. The type of Commit is computed based on the type of the value, the type of the meta info as well as the type of the parents.
For the first commit we get:
```
struct Commit { meta: M, parents: Set<Ref<Cycle<0>>>, value: T, }
```
As long as we continue to commit values with type T and meta of type M that type stays the same.
When we later do a commit with value of type U and meta of type N we get:
```
struct Commit { meta: N, parents: Set<Ref<struct Commit { meta: M | N, parents: Set<Ref<Cycle<0>>>, value: T | U }>>, value: U, }
```
Similarly if we do a commit with a different type for the meta info.
The new type gets combined as a union type for the value/meta of the inner commit struct.
func NewRemoteDatabaseServer ¶
func NewRemoteDatabaseServer(cs chunks.ChunkStore, port int) *remoteDatabaseServer
func Pull ¶
func Pull(srcDB, sinkDB Database, sourceRef, sinkHeadRef types.Ref, concurrency int, progressCh chan PullProgress)
Pull objects that descends from sourceRef from srcDB to sinkDB. sinkHeadRef should point to a Commit (in sinkDB) that's an ancestor of sourceRef. This allows the algorithm to figure out which portions of data are already present in sinkDB and skip copying them.
Types ¶
type Database ¶
type Database interface { // To implement types.ValueWriter, Database implementations provide WriteValue(). WriteValue() writes v to this Database, though v is not guaranteed to be be persistent until after a subsequent Commit(). The return value is the Ref of v. types.ValueWriter types.ValueReader io.Closer // MaybeHead returns the current Head Commit of this Database, which contains the current root of the Database's value tree, if available. If not, it returns a new Commit and 'false'. MaybeHead(datasetID string) (types.Struct, bool) // MaybeHeadRef returns the types.Ref of the Head Commit of this Database, and true, if available. If not, it returns an invalid types.Ref and false. MaybeHeadRef(datasetID string) (types.Ref, bool) // Head returns the current head Commit, which contains the current root of the Database's value tree. Head(datasetID string) types.Struct // HeadRef returns the ref of the current head Commit. See Head(datasetID). HeadRef(datasetID string) types.Ref // Datasets returns the root of the database which is a MapOfStringToRefOfCommit where string is a datasetID. Datasets() types.Map // Commit updates the Commit that datasetID in this database points at. All Values that have been written to this Database are guaranteed to be persistent after Commit(). If the update cannot be performed, e.g., because of a conflict, error will non-nil. The newest snapshot of the database is always returned. Commit(datasetID string, commit types.Struct) (Database, error) // Delete removes the Dataset named datasetID from the map at the root of the Database. The Dataset data is not necessarily cleaned up at this time, but may be garbage collected in the future. If the update cannot be performed, e.g., because of a conflict, error will non-nil. The newest snapshot of the database is always returned. Delete(datasetID string) (Database, error) // contains filtered or unexported methods }
Database provides versioned storage for noms values. Each Database instance represents one moment in history. Heads() returns the Commit from each active fork at that moment. The Commit() method returns a new Database, representing a new moment in history.
func NewDatabase ¶
func NewDatabase(cs chunks.ChunkStore) Database
type Factory ¶
type Factory interface { Create(string) (Database, bool) // Shutter shuts down the factory. Subsequent calls to Create() will fail. Shutter() }
Factory allows the creation of namespaced Database instances. The details of how namespaces are separated is left up to the particular implementation of Factory and Database.
func NewRemoteStoreFactory ¶
type Handler ¶
type Handler func(w http.ResponseWriter, req *http.Request, ps URLParams, cs chunks.ChunkStore)
type LocalDatabase ¶
type LocalDatabase struct {
// contains filtered or unexported fields
}
Database provides versioned storage for noms values. Each Database instance represents one moment in history. Heads() returns the Commit from each active fork at that moment. The Commit() method returns a new Database, representing a new moment in history.
func (*LocalDatabase) MaybeHeadRef ¶
type PullProgress ¶
type PullProgress struct {
DoneCount, KnownCount, DoneBytes uint64
}
type RemoteDatabaseClient ¶
type RemoteDatabaseClient struct {
// contains filtered or unexported fields
}
Database provides versioned storage for noms values. Each Database instance represents one moment in history. Heads() returns the Commit from each active fork at that moment. The Commit() method returns a new Database, representing a new moment in history.
func NewRemoteDatabase ¶
func NewRemoteDatabase(baseURL, auth string) *RemoteDatabaseClient
func (*RemoteDatabaseClient) Delete ¶
func (rds *RemoteDatabaseClient) Delete(datasetID string) (Database, error)
func (*RemoteDatabaseClient) MaybeHeadRef ¶
type RemoteStoreFactory ¶
type RemoteStoreFactory struct {
// contains filtered or unexported fields
}
func (RemoteStoreFactory) CreateStore ¶
func (f RemoteStoreFactory) CreateStore(ns string) Database
func (RemoteStoreFactory) Shutter ¶
func (f RemoteStoreFactory) Shutter()