datas

package
v0.0.0-...-160d89c Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2016 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParentsField = "parents"
	ValueField   = "value"
	MetaField    = "meta"
)
View Source
const NomsVersionHeader = "x-noms-vers"

NomsVersionHeader is the name of the header that Noms clients and servers must set in every request/response.

Variables

View Source
var (
	ErrOptimisticLockFailed = errors.New("Optimistic lock failed on database Root update")
	ErrMergeNeeded          = errors.New("Dataset head is not ancestor of commit")
)
View Source
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 IsCommitType(t *types.Type) bool

func NewCommit

func NewCommit(value types.Value, parents types.Set, meta types.Struct) types.Struct

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

func NewRemoteStoreFactory(host, auth string) Factory

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

func (ds *LocalDatabase) Close() error

func (*LocalDatabase) Commit

func (lds *LocalDatabase) Commit(datasetID string, commit types.Struct) (Database, error)

func (*LocalDatabase) Datasets

func (ds *LocalDatabase) Datasets() types.Map

func (*LocalDatabase) Delete

func (lds *LocalDatabase) Delete(datasetID string) (Database, error)

func (*LocalDatabase) Head

func (ds *LocalDatabase) Head(datasetID string) types.Struct

func (*LocalDatabase) HeadRef

func (ds *LocalDatabase) HeadRef(datasetID string) types.Ref

func (*LocalDatabase) MaybeHead

func (ds *LocalDatabase) MaybeHead(datasetID string) (types.Struct, bool)

func (*LocalDatabase) MaybeHeadRef

func (ds *LocalDatabase) MaybeHeadRef(datasetID string) (types.Ref, bool)

func (*LocalDatabase) ReadValue

func (ds *LocalDatabase) ReadValue(r hash.Hash) types.Value

func (*LocalDatabase) WriteValue

func (ds *LocalDatabase) WriteValue(v types.Value) types.Ref

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

func (ds *RemoteDatabaseClient) Close() error

func (*RemoteDatabaseClient) Commit

func (rds *RemoteDatabaseClient) Commit(datasetID string, commit types.Struct) (Database, error)

func (*RemoteDatabaseClient) Datasets

func (ds *RemoteDatabaseClient) Datasets() types.Map

func (*RemoteDatabaseClient) Delete

func (rds *RemoteDatabaseClient) Delete(datasetID string) (Database, error)

func (*RemoteDatabaseClient) Head

func (ds *RemoteDatabaseClient) Head(datasetID string) types.Struct

func (*RemoteDatabaseClient) HeadRef

func (ds *RemoteDatabaseClient) HeadRef(datasetID string) types.Ref

func (*RemoteDatabaseClient) MaybeHead

func (ds *RemoteDatabaseClient) MaybeHead(datasetID string) (types.Struct, bool)

func (*RemoteDatabaseClient) MaybeHeadRef

func (ds *RemoteDatabaseClient) MaybeHeadRef(datasetID string) (types.Ref, bool)

func (*RemoteDatabaseClient) ReadValue

func (ds *RemoteDatabaseClient) ReadValue(r hash.Hash) types.Value

func (*RemoteDatabaseClient) WriteValue

func (ds *RemoteDatabaseClient) WriteValue(v types.Value) types.Ref

type RemoteStoreFactory

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

func (RemoteStoreFactory) Create

func (f RemoteStoreFactory) Create(ns string) (Database, bool)

func (RemoteStoreFactory) CreateStore

func (f RemoteStoreFactory) CreateStore(ns string) Database

func (RemoteStoreFactory) Shutter

func (f RemoteStoreFactory) Shutter()

type URLParams

type URLParams interface {
	ByName(string) string
}

Jump to

Keyboard shortcuts

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